<!Doctype html>
<html>
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
	<meta name="viewport" content="width=device-width, initial-scale=1.0" />
	<title>7.5 Verilog FFT 设计 | 菜鸟教程</title>

  <meta name='robots' content='max-image-preview:large' />
<link rel='stylesheet' id='classic-theme-styles-css' href='../0/classic-themes.min.css?ver=6.2' type='text/css' media='all' />
<link rel="canonical" href="../w3cnote/verilog-fft.html" />
<meta name="keywords" content="7.5 Verilog FFT 设计">
<meta name="description" content="FFT（Fast Fourier Transform），快速傅立叶变换，是一种 DFT（离散傅里叶变换）的高效算法。在以时频变换分析为基础的数字处理方法中，有着不可替代的作用。  FFT 原理 公式推导 DFT 的运算公式为：  其中，  将离散傅里叶变换公式拆分成奇偶项，则前 N/2 个点可以表示为：  同理，后 N/2 个点可以表示为：  由此可知，后 N/2 个点的值完全可以通过计算前 N/2 个点时的中间过程值确定。对 A[k]..">
		
	<link rel="shortcut icon" href="https://static.runoob.com/images/favicon.ico">
	<link rel="stylesheet" href="../0/style.css?v=1.170" type="text/css" media="all" />	
	<link rel="stylesheet" href="../0/font-awesome.min.css" media="all" />	
  <!--[if gte IE 9]><!-->
  <script src=""></script>
  <!--<![endif]-->
  <!--[if lt IE 9]>
     <script src=""></script>
     <script src=""></script>
  <![endif]-->
  <link rel="apple-touch-icon" href="https://static.runoob.com/images/icon/mobile-icon.png"/>
  <meta name="apple-mobile-web-app-title" content="菜鸟教程">
</head>
<body>

<!--  头部 -->
<div class="container logo-search">

  <div class="col search row-search-mobile">
    <form action="index.php">
      <input class="placeholder" placeholder="搜索……" name="s" autocomplete="off">
      
    </form>
  </div>

  <div class="row">
    <div class="col logo">
      <h1><a href="../">菜鸟教程 -- 学的不仅是技术，更是梦想！</a></h1>
    </div>
        <div class="col right-list"> 
    <button class="btn btn-responsive-nav btn-inverse" data-toggle="collapse" data-target=".nav-main-collapse" id="pull" style=""> <i class="fa fa-navicon"></i> </button>
    </div>
        
    <div class="col search search-desktop last">
      <div class="search-input" >
      <form action="//www.runoob.com/" target="_blank">
        <input class="placeholder" id="s" name="s" placeholder="搜索……"  autocomplete="off" style="height: 44px;">
      </form>
      
      </div>
    </div>
  </div>
</div>



<!-- 导航栏 -->
<div class="container navigation">
    <div class="row">
        <div class="col nav">
            

                        <ul class="pc-nav" id="note-nav">
                <li><a href="../">首页</a></li>
                <li><a href="../w3cnote">笔记首页</a></li>
                <li><a href="../w3cnote/android-tutorial-intro.html" title="Android 基础入门教程">Android</a></li>
                <li><a href="../w3cnote/es6-tutorial.html" title="ES6 教程">ES6 教程</a></li>
                <li><a href="../w3cnote/ten-sorting-algorithm.html" title="排序算法">排序算法</a></li>
                <li><a href="../w3cnote/hadoop-tutorial.html" title="Hadoop 教程">Hadoop</a></li>
                <li><a href="../w3cnote/zookeeper-tutorial.html" title="Zookeeper 教程">Zookeeper</a></li>
                <li><a href="../w3cnote/verilog-tutorial.html" title="Verilog 教程">Verilog</a></li>
                <li><a href="../w3cnote_genre/code" title="编程技术">编程技术</a></li> 
                <li><a href="../w3cnote_genre/coderlife" title="程序员人生">程序员人生</a></li>
                
                <!--<li><a href="javascript:;" class="runoob-pop">登录</a></li>
                
                
                        <li>
                <a style="font-weight:bold;" href="../linux/linux-tutorial.html#yunserver" target="_blank" onclick="_hmt.push(['_trackEvent', 'aliyun', 'click', 'aliyun'])" title="kkb">云服务器</a>
                </li>
                <li><a href="http://gk.link/a/104mQ" target="_blank" style="font-weight: bold;"onclick="_hmt.push(['_trackEvent', '极客时间', 'click', 'jike'])" title="我的圈子">极客时间</a></li>
            
                
                <li><a target="_blank" href="../shoppinglist" rel="nofollow">知识店铺</a></li> 
        -->
            </ul>
                        
              
            <ul class="mobile-nav">
                <li><a href="../w3cnote">首页</a></li>
                <li><a href="../w3cnote_genre/android" target="_blank" title="Android 基础入门教程">Android</a></li>
                <li><a href="../w3cnote/es6-tutorial.html" target="_blank" title="ES6 教程">ES6</a></li>
                <li><a href="../w3cnote_genre/joke" target="_blank" title="程序员笑话">逗乐</a></li>
                
                <a href="javascript:void(0)" class="search-reveal">Search</a> 
            </ul>
            
        </div>
    </div>
</div>


<!--  内容  -->
<div class="container main">
	<div class="row">

		<!--  Android 基础入门教程 start  -->
	<div class="col left-column" style="display:none;">
		<div class="tab">Verilog 教程</div>
		<div class="sidebar-box gallery-list">
			<div class="design" id="leftcolumn">  
			</div> 
		</div> 
	</div>
	<!--  Android 基础入门教程 end  -->
		<div class="col middle-column big-middle-column">
	 			<div class="article">
			<div class="article-heading">
				<h2>7.5 Verilog FFT 设计</h2>				<h3><em>分类</em> <a href="../w3cnote_genre/verilog" title="Verilog 教程" >Verilog 教程</a> </h3>
			</div>
			<div class="article-body note-body">
				<div class="article-intro">
					<p>FFT（Fast Fourier Transform），快速傅立叶变换，是一种 DFT（离散傅里叶变换）的高效算法。在以时频变换分析为基础的数字处理方法中，有着不可替代的作用。</p>

<h3>FFT 原理</h3>
<p><strong>公式推导</strong></p>
<p>DFT 的运算公式为：</p>
<p><img decoding="async" src="https://www.runoob.com/wp-content/uploads/2020/10/H9juUU8XwrsEd0yc.png" alt="" /></p>
<p>其中，</p>
<p><img decoding="async" src="https://www.runoob.com/wp-content/uploads/2020/10/EhjmOcWZm03RwY9o-1.png" alt="" /></p>
<p>将离散傅里叶变换公式拆分成奇偶项，则前 N/2 个点可以表示为：</p>
<p><img decoding="async" src="https://www.runoob.com/wp-content/uploads/2020/10/ShPtKMa3r27MshcX.png" alt="" /></p>
<p>同理，后 N/2 个点可以表示为：</p>
<p><img decoding="async" src="https://www.runoob.com/wp-content/uploads/2020/10/MMmgQxwSMAEcLjjl.png" alt="" /></p><p>
由此可知，后 N/2 个点的值完全可以通过计算前 N/2 个点时的中间过程值确定。对 A[k] 与 B[k] 继续进行奇偶分解，直至变成 2 点的 DFT，这样就可以避免很多的重复计算，实现了快速离散傅里叶变换（FFT）的过程。</p>
<p><strong>算法结构</strong></p><p>
8 点 FFT 计算的结构示意图如下。</p><p>
由图可知，只需要简单的计算几次乘法和加法，便可完成离散傅里叶变换过程，而不是对每个数据进行繁琐的相乘和累加。</p>
<p><img decoding="async" src="https://static.runoob.com/images/mix/uuE5FKpYLflJt5EF.jpg"></p>
<p><strong>重要特性</strong></p>
<p>(1) 级的概念</p>
<p>每分割一次，称为一级运算。</p><p>
设 FFT 运算点数为 N，共有 M 级运算，则它们满足：</p>
<p><img decoding="async" src="https://www.runoob.com/wp-content/uploads/2020/10/oBL12HrkSCYT6wby.png" alt="" /></p><p>
每一级运算的标识为 m = 0, 1, 2, ..., M-1。</p><p>
为了便于分割计算，FFT 点数 N 的取值经常为 2 的整数次幂。</p>
<p>
(2) 蝶形单元</p><p>
FFT 计算结构由若干个蝶形运算单元组成，每个运算单元示意图如下：</p>
<p><img decoding="async" src="https://www.runoob.com/wp-content/uploads/2020/10/VexKYoVwuj6hn1rE.gif" alt="" /></p>
<p>蝶形单元的输入输出满足：</p>
<p><img decoding="async" src="https://www.runoob.com/wp-content/uploads/2020/10/9sP3eefIuDNwQHXP.jpg" alt="" /></p>
<p>其中， <img decoding="async" src="https://www.runoob.com/wp-content/uploads/2020/10/uWayxKitgWrBaOoc.png" alt="" /></p><p>
每一个蝶形单元运算时，进行了一次乘法和两次加法。</p><p>
每一级中，均有 N/2 个蝶形单元。</p><p>
故完成一次 FFT 所需要的乘法次数和加法次数分别为：</p>
<p><img decoding="async" src="https://www.runoob.com/wp-content/uploads/2020/10/CRxV0zepPlkuX52I.png" alt="" /></p>

<p>(3) 组的概念</p>
<p>每一级 N/2 个蝶形单元可分为若干组，每一组有着相同的结构与<img decoding="async" src="https://www.runoob.com/wp-content/uploads/2020/10/rEc1ZdxQpj2YT1lg.png" alt="" />因子分布。</p><p>
例如 m=0 时，可以分为 N/2=4 组。</p>
<p>m=1 时，可以分为 N/4=2 组。</p>
<p>m=M-1 时，此时只能分为 1 组。</p>

<p>(4) <img decoding="async" src="https://www.runoob.com/wp-content/uploads/2020/10/rEc1ZdxQpj2YT1lg.png" alt="" />因子分布
<img decoding="async" src="https://www.runoob.com/wp-content/uploads/2020/10/pSLdneHbbRSopxSr.png" alt="" />因子存在于 m 级，其中 <img decoding="async" src="https://www.runoob.com/wp-content/uploads/2020/10/4SUEFQHUCuPswYnR.png" alt="" />。</p>
<p>在 8 点 FFT 第二级运算中，即 m=1 ，蝶形运算因子可以化简为：</p>
<p><img decoding="async" src="https://www.runoob.com/wp-content/uploads/2020/10/c1RNmtc0hUnyRWbY.png" alt="" /></p>
<p>
(5) 码位倒置</p><p>
对于 N=8 点的 FFT 计算，X(0) ~ X(7) 位置对应的 2 进制码为：</p>
<pre>X(000), X(001), X(010), X(011), X(100), X(101), X(110), X(111)</pre>
<p>将其位置的 2 进制码进行翻转：</p>
<pre>X(000), X(100), X(010), X(110), X(001), X(101), X(011), X(111)</pre>
<p>此时位置对应的 10 进制为：</p>
<pre>X(0), X(4), X(2), X(6), X(1), X(5), X(3), X(7)</pre>
<p>恰好对应 FFT 第一级输入数据的顺序。</p>
<p>该特性有利于 FFT 的编程实现。</p>

<h3>FFT 设计</h3>
<p><strong>设计说明</strong></p><p>
为了利用仿真简单的说明 FFT 的变换过程，数据点数取较小的值 8。</p><p>
如果数据是串行输入，需要先进行缓存，所以设计时数据输入方式为并行。</p><p>
数据输入分为实部和虚部共 2 部分，所以计算结果也分为实部和虚部。</p><p>
设计采用流水结构，暂不考虑资源消耗的问题。</p><p>
为了使设计结构更加简单，这里做一步妥协，乘法计算直接使用乘号。如果 FFT 设计应用于实际，一定要将乘法结构换成可以流水的乘法器，或使用官方提供的效率较高的乘法器 IP。</p>
<p><strong>蝶形单元设计</strong></p><p>
蝶形单元为定点运算，需要对旋转因子进行定点量化。</p><p>
借助 matlab 将旋转因子扩大 8192 倍（左移 13 位），可参考附录。</p><p>
为了防止蝶形运算中的乘法和加法导致位宽逐级增大，每一级运算完成后，要对输出数据进行固定位宽的截位，也可去掉旋转因子倍数增大而带来的影响。
代码如下：</p>
<div class="example"><h2 class="example">实例</h2> <div class="example_code">
<span style="color: #008800;">`timescale</span> <span style="color: #ff0055;">1ns</span><span style="color: #5D478B;">/</span><span style="color: #ff0055;">100ps</span><br />
<span style="color: #00008B; font-style: italic;">/**************** butter unit *************************<br />
Xm(p) ------------------------&gt; Xm+1(p)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;- &nbsp; &nbsp; &nbsp; &nbsp;-&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;- &nbsp; &nbsp;-<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; -<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; - &nbsp; -<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; - &nbsp; &nbsp; &nbsp; &nbsp;-&gt;<br />
Xm(q) ------------------------&gt; Xm+1(q)<br />
&nbsp; &nbsp; &nbsp; Wn &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;-1<br />
*/</span><span style="color: #00008B; font-style: italic;">/////////////////////////////////////////////////////</span><br />
<span style="color: #A52A2A; font-weight: bold;">module</span> butterfly<br />
&nbsp; &nbsp; <span style="color: #9F79EE;">&#40;</span><br />
&nbsp; &nbsp; &nbsp;<span style="color: #A52A2A; font-weight: bold;">input</span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; clk<span style="color: #5D478B;">,</span><br />
&nbsp; &nbsp; &nbsp;<span style="color: #A52A2A; font-weight: bold;">input</span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; rstn<span style="color: #5D478B;">,</span><br />
&nbsp; &nbsp; &nbsp;<span style="color: #A52A2A; font-weight: bold;">input</span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; en<span style="color: #5D478B;">,</span><br />
&nbsp; &nbsp; &nbsp;<span style="color: #A52A2A; font-weight: bold;">input</span> <span style="color: #A52A2A; font-weight: bold;">signed</span> <span style="color: #9F79EE;">&#91;</span><span style="color: #ff0055;">23</span><span style="color: #5D478B;">:</span><span style="color: #ff0055;">0</span><span style="color: #9F79EE;">&#93;</span> &nbsp; &nbsp; &nbsp; &nbsp; xp_real<span style="color: #5D478B;">,</span> <span style="color: #00008B; font-style: italic;">// Xm(p)</span><br />
&nbsp; &nbsp; &nbsp;<span style="color: #A52A2A; font-weight: bold;">input</span> <span style="color: #A52A2A; font-weight: bold;">signed</span> <span style="color: #9F79EE;">&#91;</span><span style="color: #ff0055;">23</span><span style="color: #5D478B;">:</span><span style="color: #ff0055;">0</span><span style="color: #9F79EE;">&#93;</span> &nbsp; &nbsp; &nbsp; &nbsp; xp_imag<span style="color: #5D478B;">,</span><br />
&nbsp; &nbsp; &nbsp;<span style="color: #A52A2A; font-weight: bold;">input</span> <span style="color: #A52A2A; font-weight: bold;">signed</span> <span style="color: #9F79EE;">&#91;</span><span style="color: #ff0055;">23</span><span style="color: #5D478B;">:</span><span style="color: #ff0055;">0</span><span style="color: #9F79EE;">&#93;</span> &nbsp; &nbsp; &nbsp; &nbsp; xq_real<span style="color: #5D478B;">,</span> <span style="color: #00008B; font-style: italic;">// Xm(q)</span><br />
&nbsp; &nbsp; &nbsp;<span style="color: #A52A2A; font-weight: bold;">input</span> <span style="color: #A52A2A; font-weight: bold;">signed</span> <span style="color: #9F79EE;">&#91;</span><span style="color: #ff0055;">23</span><span style="color: #5D478B;">:</span><span style="color: #ff0055;">0</span><span style="color: #9F79EE;">&#93;</span> &nbsp; &nbsp; &nbsp; &nbsp; xq_imag<span style="color: #5D478B;">,</span><br />
&nbsp; &nbsp; &nbsp;<span style="color: #A52A2A; font-weight: bold;">input</span> <span style="color: #A52A2A; font-weight: bold;">signed</span> <span style="color: #9F79EE;">&#91;</span><span style="color: #ff0055;">15</span><span style="color: #5D478B;">:</span><span style="color: #ff0055;">0</span><span style="color: #9F79EE;">&#93;</span> &nbsp; &nbsp; &nbsp; &nbsp; factor_real<span style="color: #5D478B;">,</span> <span style="color: #00008B; font-style: italic;">// Wnr</span><br />
&nbsp; &nbsp; &nbsp;<span style="color: #A52A2A; font-weight: bold;">input</span> <span style="color: #A52A2A; font-weight: bold;">signed</span> <span style="color: #9F79EE;">&#91;</span><span style="color: #ff0055;">15</span><span style="color: #5D478B;">:</span><span style="color: #ff0055;">0</span><span style="color: #9F79EE;">&#93;</span> &nbsp; &nbsp; &nbsp; &nbsp; factor_imag<span style="color: #5D478B;">,</span><br />
<br />
&nbsp; &nbsp; &nbsp;<span style="color: #A52A2A; font-weight: bold;">output</span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;valid<span style="color: #5D478B;">,</span><br />
&nbsp; &nbsp; &nbsp;<span style="color: #A52A2A; font-weight: bold;">output</span> <span style="color: #A52A2A; font-weight: bold;">signed</span> <span style="color: #9F79EE;">&#91;</span><span style="color: #ff0055;">23</span><span style="color: #5D478B;">:</span><span style="color: #ff0055;">0</span><span style="color: #9F79EE;">&#93;</span> &nbsp; &nbsp; &nbsp; &nbsp;yp_real<span style="color: #5D478B;">,</span> <span style="color: #00008B; font-style: italic;">//Xm+1(p)</span><br />
&nbsp; &nbsp; &nbsp;<span style="color: #A52A2A; font-weight: bold;">output</span> <span style="color: #A52A2A; font-weight: bold;">signed</span> <span style="color: #9F79EE;">&#91;</span><span style="color: #ff0055;">23</span><span style="color: #5D478B;">:</span><span style="color: #ff0055;">0</span><span style="color: #9F79EE;">&#93;</span> &nbsp; &nbsp; &nbsp; &nbsp;yp_imag<span style="color: #5D478B;">,</span><br />
&nbsp; &nbsp; &nbsp;<span style="color: #A52A2A; font-weight: bold;">output</span> <span style="color: #A52A2A; font-weight: bold;">signed</span> <span style="color: #9F79EE;">&#91;</span><span style="color: #ff0055;">23</span><span style="color: #5D478B;">:</span><span style="color: #ff0055;">0</span><span style="color: #9F79EE;">&#93;</span> &nbsp; &nbsp; &nbsp; &nbsp;yq_real<span style="color: #5D478B;">,</span> <span style="color: #00008B; font-style: italic;">//Xm+1(q)</span><br />
&nbsp; &nbsp; &nbsp;<span style="color: #A52A2A; font-weight: bold;">output</span> <span style="color: #A52A2A; font-weight: bold;">signed</span> <span style="color: #9F79EE;">&#91;</span><span style="color: #ff0055;">23</span><span style="color: #5D478B;">:</span><span style="color: #ff0055;">0</span><span style="color: #9F79EE;">&#93;</span> &nbsp; &nbsp; &nbsp; &nbsp;yq_imag<span style="color: #9F79EE;">&#41;</span><span style="color: #5D478B;">;</span><br />
<br />
&nbsp; &nbsp; <span style="color: #A52A2A; font-weight: bold;">reg</span> <span style="color: #9F79EE;">&#91;</span><span style="color: #ff0055;">4</span><span style="color: #5D478B;">:</span><span style="color: #ff0055;">0</span><span style="color: #9F79EE;">&#93;</span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;en_r <span style="color: #5D478B;">;</span><br />
&nbsp; &nbsp; <span style="color: #A52A2A; font-weight: bold;">always</span> <span style="color: #5D478B;">@</span><span style="color: #9F79EE;">&#40;</span><span style="color: #A52A2A; font-weight: bold;">posedge</span> clk <span style="color: #A52A2A; font-weight: bold;">or</span> <span style="color: #A52A2A; font-weight: bold;">negedge</span> rstn<span style="color: #9F79EE;">&#41;</span> <span style="color: #A52A2A; font-weight: bold;">begin</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #A52A2A; font-weight: bold;">if</span> <span style="color: #9F79EE;">&#40;</span><span style="color: #5D478B;">!</span>rstn<span style="color: #9F79EE;">&#41;</span> <span style="color: #A52A2A; font-weight: bold;">begin</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; en_r &nbsp; <span style="color: #5D478B;">&lt;=</span> 'b0 <span style="color: #5D478B;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #A52A2A; font-weight: bold;">end</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #A52A2A; font-weight: bold;">else</span> <span style="color: #A52A2A; font-weight: bold;">begin</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; en_r &nbsp; <span style="color: #5D478B;">&lt;=</span> <span style="color: #9F79EE;">&#123;</span>en_r<span style="color: #9F79EE;">&#91;</span><span style="color: #ff0055;">3</span><span style="color: #5D478B;">:</span><span style="color: #ff0055;">0</span><span style="color: #9F79EE;">&#93;</span><span style="color: #5D478B;">,</span> en<span style="color: #9F79EE;">&#125;</span> <span style="color: #5D478B;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #A52A2A; font-weight: bold;">end</span><br />
&nbsp; &nbsp; <span style="color: #A52A2A; font-weight: bold;">end</span><br />
<br />
&nbsp; &nbsp; <span style="color: #00008B; font-style: italic;">//=====================================================//</span><br />
&nbsp; &nbsp; <span style="color: #00008B; font-style: italic;">//(1.0) Xm(q) mutiply and Xm(p) delay</span><br />
&nbsp; &nbsp; <span style="color: #A52A2A; font-weight: bold;">reg</span> <span style="color: #A52A2A; font-weight: bold;">signed</span> <span style="color: #9F79EE;">&#91;</span><span style="color: #ff0055;">39</span><span style="color: #5D478B;">:</span><span style="color: #ff0055;">0</span><span style="color: #9F79EE;">&#93;</span> xq_wnr_real0<span style="color: #5D478B;">;</span><br />
&nbsp; &nbsp; <span style="color: #A52A2A; font-weight: bold;">reg</span> <span style="color: #A52A2A; font-weight: bold;">signed</span> <span style="color: #9F79EE;">&#91;</span><span style="color: #ff0055;">39</span><span style="color: #5D478B;">:</span><span style="color: #ff0055;">0</span><span style="color: #9F79EE;">&#93;</span> xq_wnr_real1<span style="color: #5D478B;">;</span><br />
&nbsp; &nbsp; <span style="color: #A52A2A; font-weight: bold;">reg</span> <span style="color: #A52A2A; font-weight: bold;">signed</span> <span style="color: #9F79EE;">&#91;</span><span style="color: #ff0055;">39</span><span style="color: #5D478B;">:</span><span style="color: #ff0055;">0</span><span style="color: #9F79EE;">&#93;</span> xq_wnr_imag0<span style="color: #5D478B;">;</span><br />
&nbsp; &nbsp; <span style="color: #A52A2A; font-weight: bold;">reg</span> <span style="color: #A52A2A; font-weight: bold;">signed</span> <span style="color: #9F79EE;">&#91;</span><span style="color: #ff0055;">39</span><span style="color: #5D478B;">:</span><span style="color: #ff0055;">0</span><span style="color: #9F79EE;">&#93;</span> xq_wnr_imag1<span style="color: #5D478B;">;</span><br />
&nbsp; &nbsp; <span style="color: #A52A2A; font-weight: bold;">reg</span> <span style="color: #A52A2A; font-weight: bold;">signed</span> <span style="color: #9F79EE;">&#91;</span><span style="color: #ff0055;">39</span><span style="color: #5D478B;">:</span><span style="color: #ff0055;">0</span><span style="color: #9F79EE;">&#93;</span> xp_real_d<span style="color: #5D478B;">;</span><br />
&nbsp; &nbsp; <span style="color: #A52A2A; font-weight: bold;">reg</span> <span style="color: #A52A2A; font-weight: bold;">signed</span> <span style="color: #9F79EE;">&#91;</span><span style="color: #ff0055;">39</span><span style="color: #5D478B;">:</span><span style="color: #ff0055;">0</span><span style="color: #9F79EE;">&#93;</span> xp_imag_d<span style="color: #5D478B;">;</span><br />
&nbsp; &nbsp; <span style="color: #A52A2A; font-weight: bold;">always</span> <span style="color: #5D478B;">@</span><span style="color: #9F79EE;">&#40;</span><span style="color: #A52A2A; font-weight: bold;">posedge</span> clk <span style="color: #A52A2A; font-weight: bold;">or</span> <span style="color: #A52A2A; font-weight: bold;">negedge</span> rstn<span style="color: #9F79EE;">&#41;</span> <span style="color: #A52A2A; font-weight: bold;">begin</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #A52A2A; font-weight: bold;">if</span> <span style="color: #9F79EE;">&#40;</span><span style="color: #5D478B;">!</span>rstn<span style="color: #9F79EE;">&#41;</span> <span style="color: #A52A2A; font-weight: bold;">begin</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; xp_real_d &nbsp; &nbsp;<span style="color: #5D478B;">&lt;=</span> 'b0<span style="color: #5D478B;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; xp_imag_d &nbsp; &nbsp;<span style="color: #5D478B;">&lt;=</span> 'b0<span style="color: #5D478B;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; xq_wnr_real0 <span style="color: #5D478B;">&lt;=</span> 'b0<span style="color: #5D478B;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; xq_wnr_real1 <span style="color: #5D478B;">&lt;=</span> 'b0<span style="color: #5D478B;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; xq_wnr_imag0 <span style="color: #5D478B;">&lt;=</span> 'b0<span style="color: #5D478B;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; xq_wnr_imag1 <span style="color: #5D478B;">&lt;=</span> 'b0<span style="color: #5D478B;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #A52A2A; font-weight: bold;">end</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #A52A2A; font-weight: bold;">else</span> <span style="color: #A52A2A; font-weight: bold;">if</span> <span style="color: #9F79EE;">&#40;</span>en<span style="color: #9F79EE;">&#41;</span> <span style="color: #A52A2A; font-weight: bold;">begin</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; xq_wnr_real0 <span style="color: #5D478B;">&lt;=</span> xq_real <span style="color: #5D478B;">*</span> factor_real<span style="color: #5D478B;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; xq_wnr_real1 <span style="color: #5D478B;">&lt;=</span> xq_imag <span style="color: #5D478B;">*</span> factor_imag<span style="color: #5D478B;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; xq_wnr_imag0 <span style="color: #5D478B;">&lt;=</span> xq_real <span style="color: #5D478B;">*</span> factor_imag<span style="color: #5D478B;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; xq_wnr_imag1 <span style="color: #5D478B;">&lt;=</span> xq_imag <span style="color: #5D478B;">*</span> factor_real<span style="color: #5D478B;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #00008B; font-style: italic;">//expanding 8192 times as Wnr</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; xp_real_d &nbsp; &nbsp;<span style="color: #5D478B;">&lt;=</span> <span style="color: #9F79EE;">&#123;</span><span style="color: #9F79EE;">&#123;</span><span style="color: #ff0055;">4</span><span style="color: #9F79EE;">&#123;</span>xp_real<span style="color: #9F79EE;">&#91;</span><span style="color: #ff0055;">23</span><span style="color: #9F79EE;">&#93;</span><span style="color: #9F79EE;">&#125;</span><span style="color: #9F79EE;">&#125;</span><span style="color: #5D478B;">,</span> xp_real<span style="color: #9F79EE;">&#91;</span><span style="color: #ff0055;">22</span><span style="color: #5D478B;">:</span><span style="color: #ff0055;">0</span><span style="color: #9F79EE;">&#93;</span><span style="color: #5D478B;">,</span> <span style="color: #ff0055;">1</span><span style="color: #ff0055;">3'b0</span><span style="color: #9F79EE;">&#125;</span><span style="color: #5D478B;">;</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; xp_imag_d &nbsp; &nbsp;<span style="color: #5D478B;">&lt;=</span> <span style="color: #9F79EE;">&#123;</span><span style="color: #9F79EE;">&#123;</span><span style="color: #ff0055;">4</span><span style="color: #9F79EE;">&#123;</span>xp_imag<span style="color: #9F79EE;">&#91;</span><span style="color: #ff0055;">23</span><span style="color: #9F79EE;">&#93;</span><span style="color: #9F79EE;">&#125;</span><span style="color: #9F79EE;">&#125;</span><span style="color: #5D478B;">,</span> xp_imag<span style="color: #9F79EE;">&#91;</span><span style="color: #ff0055;">22</span><span style="color: #5D478B;">:</span><span style="color: #ff0055;">0</span><span style="color: #9F79EE;">&#93;</span><span style="color: #5D478B;">,</span> <span style="color: #ff0055;">1</span><span style="color: #ff0055;">3'b0</span><span style="color: #9F79EE;">&#125;</span><span style="color: #5D478B;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #A52A2A; font-weight: bold;">end</span><br />
&nbsp; &nbsp; <span style="color: #A52A2A; font-weight: bold;">end</span><br />
<br />
&nbsp; &nbsp; <span style="color: #00008B; font-style: italic;">//(1.1) get Xm(q) mutiplied-results and Xm(p) delay again</span><br />
&nbsp; &nbsp; <span style="color: #A52A2A; font-weight: bold;">reg</span> <span style="color: #A52A2A; font-weight: bold;">signed</span> <span style="color: #9F79EE;">&#91;</span><span style="color: #ff0055;">39</span><span style="color: #5D478B;">:</span><span style="color: #ff0055;">0</span><span style="color: #9F79EE;">&#93;</span> xp_real_d1<span style="color: #5D478B;">;</span><br />
&nbsp; &nbsp; <span style="color: #A52A2A; font-weight: bold;">reg</span> <span style="color: #A52A2A; font-weight: bold;">signed</span> <span style="color: #9F79EE;">&#91;</span><span style="color: #ff0055;">39</span><span style="color: #5D478B;">:</span><span style="color: #ff0055;">0</span><span style="color: #9F79EE;">&#93;</span> xp_imag_d1<span style="color: #5D478B;">;</span><br />
&nbsp; &nbsp; <span style="color: #A52A2A; font-weight: bold;">reg</span> <span style="color: #A52A2A; font-weight: bold;">signed</span> <span style="color: #9F79EE;">&#91;</span><span style="color: #ff0055;">39</span><span style="color: #5D478B;">:</span><span style="color: #ff0055;">0</span><span style="color: #9F79EE;">&#93;</span> xq_wnr_real<span style="color: #5D478B;">;</span><br />
&nbsp; &nbsp; <span style="color: #A52A2A; font-weight: bold;">reg</span> <span style="color: #A52A2A; font-weight: bold;">signed</span> <span style="color: #9F79EE;">&#91;</span><span style="color: #ff0055;">39</span><span style="color: #5D478B;">:</span><span style="color: #ff0055;">0</span><span style="color: #9F79EE;">&#93;</span> xq_wnr_imag<span style="color: #5D478B;">;</span><br />
&nbsp; &nbsp; <span style="color: #A52A2A; font-weight: bold;">always</span> <span style="color: #5D478B;">@</span><span style="color: #9F79EE;">&#40;</span><span style="color: #A52A2A; font-weight: bold;">posedge</span> clk <span style="color: #A52A2A; font-weight: bold;">or</span> <span style="color: #A52A2A; font-weight: bold;">negedge</span> rstn<span style="color: #9F79EE;">&#41;</span> <span style="color: #A52A2A; font-weight: bold;">begin</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #A52A2A; font-weight: bold;">if</span> <span style="color: #9F79EE;">&#40;</span><span style="color: #5D478B;">!</span>rstn<span style="color: #9F79EE;">&#41;</span> <span style="color: #A52A2A; font-weight: bold;">begin</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; xp_real_d1 &nbsp; &nbsp; <span style="color: #5D478B;">&lt;=</span> 'b0<span style="color: #5D478B;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; xp_imag_d1 &nbsp; &nbsp; <span style="color: #5D478B;">&lt;=</span> 'b0<span style="color: #5D478B;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; xq_wnr_real &nbsp; &nbsp;<span style="color: #5D478B;">&lt;=</span> 'b0 <span style="color: #5D478B;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; xq_wnr_imag &nbsp; &nbsp;<span style="color: #5D478B;">&lt;=</span> 'b0 <span style="color: #5D478B;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #A52A2A; font-weight: bold;">end</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #A52A2A; font-weight: bold;">else</span> <span style="color: #A52A2A; font-weight: bold;">if</span> <span style="color: #9F79EE;">&#40;</span>en_r<span style="color: #9F79EE;">&#91;</span><span style="color: #ff0055;">0</span><span style="color: #9F79EE;">&#93;</span><span style="color: #9F79EE;">&#41;</span> <span style="color: #A52A2A; font-weight: bold;">begin</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; xp_real_d1 &nbsp; &nbsp; <span style="color: #5D478B;">&lt;=</span> xp_real_d<span style="color: #5D478B;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; xp_imag_d1 &nbsp; &nbsp; <span style="color: #5D478B;">&lt;=</span> xp_imag_d<span style="color: #5D478B;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #00008B; font-style: italic;">//提前设置好位宽余量，防止数据溢出</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; xq_wnr_real &nbsp; &nbsp;<span style="color: #5D478B;">&lt;=</span> xq_wnr_real0 <span style="color: #5D478B;">-</span> xq_wnr_real1 <span style="color: #5D478B;">;</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; xq_wnr_imag &nbsp; &nbsp;<span style="color: #5D478B;">&lt;=</span> xq_wnr_imag0 <span style="color: #5D478B;">+</span> xq_wnr_imag1 <span style="color: #5D478B;">;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #A52A2A; font-weight: bold;">end</span><br />
&nbsp; &nbsp; <span style="color: #A52A2A; font-weight: bold;">end</span><br />
<br />
&nbsp; &nbsp;<span style="color: #00008B; font-style: italic;">//======================================================//</span><br />
&nbsp; &nbsp;<span style="color: #00008B; font-style: italic;">//(2.0) butter results</span><br />
&nbsp; &nbsp; <span style="color: #A52A2A; font-weight: bold;">reg</span> <span style="color: #A52A2A; font-weight: bold;">signed</span> <span style="color: #9F79EE;">&#91;</span><span style="color: #ff0055;">39</span><span style="color: #5D478B;">:</span><span style="color: #ff0055;">0</span><span style="color: #9F79EE;">&#93;</span> yp_real_r<span style="color: #5D478B;">;</span><br />
&nbsp; &nbsp; <span style="color: #A52A2A; font-weight: bold;">reg</span> <span style="color: #A52A2A; font-weight: bold;">signed</span> <span style="color: #9F79EE;">&#91;</span><span style="color: #ff0055;">39</span><span style="color: #5D478B;">:</span><span style="color: #ff0055;">0</span><span style="color: #9F79EE;">&#93;</span> yp_imag_r<span style="color: #5D478B;">;</span><br />
&nbsp; &nbsp; <span style="color: #A52A2A; font-weight: bold;">reg</span> <span style="color: #A52A2A; font-weight: bold;">signed</span> <span style="color: #9F79EE;">&#91;</span><span style="color: #ff0055;">39</span><span style="color: #5D478B;">:</span><span style="color: #ff0055;">0</span><span style="color: #9F79EE;">&#93;</span> yq_real_r<span style="color: #5D478B;">;</span><br />
&nbsp; &nbsp; <span style="color: #A52A2A; font-weight: bold;">reg</span> <span style="color: #A52A2A; font-weight: bold;">signed</span> <span style="color: #9F79EE;">&#91;</span><span style="color: #ff0055;">39</span><span style="color: #5D478B;">:</span><span style="color: #ff0055;">0</span><span style="color: #9F79EE;">&#93;</span> yq_imag_r<span style="color: #5D478B;">;</span><br />
&nbsp; &nbsp; <span style="color: #A52A2A; font-weight: bold;">always</span> <span style="color: #5D478B;">@</span><span style="color: #9F79EE;">&#40;</span><span style="color: #A52A2A; font-weight: bold;">posedge</span> clk <span style="color: #A52A2A; font-weight: bold;">or</span> <span style="color: #A52A2A; font-weight: bold;">negedge</span> rstn<span style="color: #9F79EE;">&#41;</span> <span style="color: #A52A2A; font-weight: bold;">begin</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #A52A2A; font-weight: bold;">if</span> <span style="color: #9F79EE;">&#40;</span><span style="color: #5D478B;">!</span>rstn<span style="color: #9F79EE;">&#41;</span> <span style="color: #A52A2A; font-weight: bold;">begin</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; yp_real_r &nbsp; &nbsp; &nbsp;<span style="color: #5D478B;">&lt;=</span> 'b0<span style="color: #5D478B;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; yp_imag_r &nbsp; &nbsp; &nbsp;<span style="color: #5D478B;">&lt;=</span> 'b0<span style="color: #5D478B;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; yq_real_r &nbsp; &nbsp; &nbsp;<span style="color: #5D478B;">&lt;=</span> 'b0<span style="color: #5D478B;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; yq_imag_r &nbsp; &nbsp; &nbsp;<span style="color: #5D478B;">&lt;=</span> 'b0<span style="color: #5D478B;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #A52A2A; font-weight: bold;">end</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #A52A2A; font-weight: bold;">else</span> <span style="color: #A52A2A; font-weight: bold;">if</span> <span style="color: #9F79EE;">&#40;</span>en_r<span style="color: #9F79EE;">&#91;</span><span style="color: #ff0055;">1</span><span style="color: #9F79EE;">&#93;</span><span style="color: #9F79EE;">&#41;</span> <span style="color: #A52A2A; font-weight: bold;">begin</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; yp_real_r &nbsp; &nbsp; &nbsp;<span style="color: #5D478B;">&lt;=</span> xp_real_d1 <span style="color: #5D478B;">+</span> xq_wnr_real<span style="color: #5D478B;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; yp_imag_r &nbsp; &nbsp; &nbsp;<span style="color: #5D478B;">&lt;=</span> xp_imag_d1 <span style="color: #5D478B;">+</span> xq_wnr_imag<span style="color: #5D478B;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; yq_real_r &nbsp; &nbsp; &nbsp;<span style="color: #5D478B;">&lt;=</span> xp_real_d1 <span style="color: #5D478B;">-</span> xq_wnr_real<span style="color: #5D478B;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; yq_imag_r &nbsp; &nbsp; &nbsp;<span style="color: #5D478B;">&lt;=</span> xp_imag_d1 <span style="color: #5D478B;">-</span> xq_wnr_imag<span style="color: #5D478B;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #A52A2A; font-weight: bold;">end</span><br />
&nbsp; &nbsp; <span style="color: #A52A2A; font-weight: bold;">end</span><br />
<br />
&nbsp; &nbsp; <span style="color: #00008B; font-style: italic;">//(3) discard the low 13bits because of Wnr</span><br />
&nbsp; &nbsp; <span style="color: #A52A2A; font-weight: bold;">assign</span> yp_real <span style="color: #5D478B;">=</span> <span style="color: #9F79EE;">&#123;</span>yp_real_r<span style="color: #9F79EE;">&#91;</span><span style="color: #ff0055;">39</span><span style="color: #9F79EE;">&#93;</span><span style="color: #5D478B;">,</span> yp_real_r<span style="color: #9F79EE;">&#91;</span><span style="color: #ff0055;">13</span><span style="color: #5D478B;">+</span><span style="color: #ff0055;">23</span><span style="color: #5D478B;">:</span><span style="color: #ff0055;">13</span><span style="color: #9F79EE;">&#93;</span><span style="color: #9F79EE;">&#125;</span><span style="color: #5D478B;">;</span><br />
&nbsp; &nbsp; <span style="color: #A52A2A; font-weight: bold;">assign</span> yp_imag <span style="color: #5D478B;">=</span> <span style="color: #9F79EE;">&#123;</span>yp_imag_r<span style="color: #9F79EE;">&#91;</span><span style="color: #ff0055;">39</span><span style="color: #9F79EE;">&#93;</span><span style="color: #5D478B;">,</span> yp_imag_r<span style="color: #9F79EE;">&#91;</span><span style="color: #ff0055;">13</span><span style="color: #5D478B;">+</span><span style="color: #ff0055;">23</span><span style="color: #5D478B;">:</span><span style="color: #ff0055;">13</span><span style="color: #9F79EE;">&#93;</span><span style="color: #9F79EE;">&#125;</span><span style="color: #5D478B;">;</span><br />
&nbsp; &nbsp; <span style="color: #A52A2A; font-weight: bold;">assign</span> yq_real <span style="color: #5D478B;">=</span> <span style="color: #9F79EE;">&#123;</span>yq_real_r<span style="color: #9F79EE;">&#91;</span><span style="color: #ff0055;">39</span><span style="color: #9F79EE;">&#93;</span><span style="color: #5D478B;">,</span> yq_real_r<span style="color: #9F79EE;">&#91;</span><span style="color: #ff0055;">13</span><span style="color: #5D478B;">+</span><span style="color: #ff0055;">23</span><span style="color: #5D478B;">:</span><span style="color: #ff0055;">13</span><span style="color: #9F79EE;">&#93;</span><span style="color: #9F79EE;">&#125;</span><span style="color: #5D478B;">;</span><br />
&nbsp; &nbsp; <span style="color: #A52A2A; font-weight: bold;">assign</span> yq_imag <span style="color: #5D478B;">=</span> <span style="color: #9F79EE;">&#123;</span>yq_imag_r<span style="color: #9F79EE;">&#91;</span><span style="color: #ff0055;">39</span><span style="color: #9F79EE;">&#93;</span><span style="color: #5D478B;">,</span> yq_imag_r<span style="color: #9F79EE;">&#91;</span><span style="color: #ff0055;">13</span><span style="color: #5D478B;">+</span><span style="color: #ff0055;">23</span><span style="color: #5D478B;">:</span><span style="color: #ff0055;">13</span><span style="color: #9F79EE;">&#93;</span><span style="color: #9F79EE;">&#125;</span><span style="color: #5D478B;">;</span><br />
&nbsp; &nbsp; <span style="color: #A52A2A; font-weight: bold;">assign</span> valid &nbsp; <span style="color: #5D478B;">=</span> en_r<span style="color: #9F79EE;">&#91;</span><span style="color: #ff0055;">2</span><span style="color: #9F79EE;">&#93;</span><span style="color: #5D478B;">;</span><br />
<br />
<span style="color: #A52A2A; font-weight: bold;">endmodule</span><br />
</div></div>
<p><strong>顶层例化</strong></p><p>
根据 FFT 算法结构示意图，将蝶形单元例化，完成最后的 FFT 功能。</p><p>
可根据每一级蝶形单元的输入输出对应关系，依次手动例化 12 次，也可利用 generate 进行例化，此时就需要非常熟悉 FFT 中"组"和"级"的特点：</p>
<ul><li>
<p>(1) 8 点 FFT 设计，需要 3 级运算，每一级有 4 个蝶形单元，每一级的组数目分别是 4、2、1。</p></li><li>
<p>(2) 每一级的组内一个蝶形单元中两个输入端口的距离恒为 <img decoding="async" src="https://www.runoob.com/wp-content/uploads/2020/10/NvYVwVblMmgU3guK.png" alt="" />（m 为级标号，对应左移运算 1&lt;&lt;m），组内两个蝶形单元的第一个输入端口间的距离为 1。</p></li><li>
<p>(3) 每一级相邻组间的第一个蝶形单元的第一个输入端口的距离为 <img decoding="async" src="https://www.runoob.com/wp-content/uploads/2020/10/t2tAjSChpY0KisHn.png" alt="" />（对应左移运算 2&lt;&lt;m）。</p></li></ul>

<p>例化代码如下。</p><p>
其中，矩阵信号 xm_real（xm_imag）的一维、二维地址是代表级和组的标识。</p><p>
在判断信号端口之间的连接关系时，使用了看似复杂的判断逻辑，而且还带有乘号，其实最终生成的电路和手动编写代码例化 12 个蝶形单元的方式是完全相同的。因为 generate 中的变量只是辅助生成实际的电路，相关值的计算判断都已经在编译时完成。这些变量更不会生成实际的电路，只是为更快速的模块例化提供了一种方法。</p>
<div class="example"><h2 class="example">实例</h2> <div class="example_code">
timescale <span style="color: #ff0055;">1ns</span><span style="color: #5D478B;">/</span><span style="color: #ff0055;">100ps</span><br />
<span style="color: #A52A2A; font-weight: bold;">module</span> fft8 <span style="color: #9F79EE;">&#40;</span><br />
&nbsp; &nbsp; <span style="color: #A52A2A; font-weight: bold;">input</span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;clk<span style="color: #5D478B;">,</span><br />
&nbsp; &nbsp; <span style="color: #A52A2A; font-weight: bold;">input</span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;rstn<span style="color: #5D478B;">,</span><br />
&nbsp; &nbsp; <span style="color: #A52A2A; font-weight: bold;">input</span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;en<span style="color: #5D478B;">,</span><br />
<br />
&nbsp; &nbsp; <span style="color: #A52A2A; font-weight: bold;">input</span> <span style="color: #A52A2A; font-weight: bold;">signed</span> <span style="color: #9F79EE;">&#91;</span><span style="color: #ff0055;">23</span><span style="color: #5D478B;">:</span><span style="color: #ff0055;">0</span><span style="color: #9F79EE;">&#93;</span> &nbsp; &nbsp; &nbsp;x0_real<span style="color: #5D478B;">,</span><br />
&nbsp; &nbsp; <span style="color: #A52A2A; font-weight: bold;">input</span> <span style="color: #A52A2A; font-weight: bold;">signed</span> <span style="color: #9F79EE;">&#91;</span><span style="color: #ff0055;">23</span><span style="color: #5D478B;">:</span><span style="color: #ff0055;">0</span><span style="color: #9F79EE;">&#93;</span> &nbsp; &nbsp; &nbsp;x0_imag<span style="color: #5D478B;">,</span><br />
&nbsp; &nbsp; <span style="color: #A52A2A; font-weight: bold;">input</span> <span style="color: #A52A2A; font-weight: bold;">signed</span> <span style="color: #9F79EE;">&#91;</span><span style="color: #ff0055;">23</span><span style="color: #5D478B;">:</span><span style="color: #ff0055;">0</span><span style="color: #9F79EE;">&#93;</span> &nbsp; &nbsp; &nbsp;x1_real<span style="color: #5D478B;">,</span><br />
&nbsp; &nbsp; <span style="color: #A52A2A; font-weight: bold;">input</span> <span style="color: #A52A2A; font-weight: bold;">signed</span> <span style="color: #9F79EE;">&#91;</span><span style="color: #ff0055;">23</span><span style="color: #5D478B;">:</span><span style="color: #ff0055;">0</span><span style="color: #9F79EE;">&#93;</span> &nbsp; &nbsp; &nbsp;x1_imag<span style="color: #5D478B;">,</span><br />
&nbsp; &nbsp; <span style="color: #A52A2A; font-weight: bold;">input</span> <span style="color: #A52A2A; font-weight: bold;">signed</span> <span style="color: #9F79EE;">&#91;</span><span style="color: #ff0055;">23</span><span style="color: #5D478B;">:</span><span style="color: #ff0055;">0</span><span style="color: #9F79EE;">&#93;</span> &nbsp; &nbsp; &nbsp;x2_real<span style="color: #5D478B;">,</span><br />
&nbsp; &nbsp; <span style="color: #A52A2A; font-weight: bold;">input</span> <span style="color: #A52A2A; font-weight: bold;">signed</span> <span style="color: #9F79EE;">&#91;</span><span style="color: #ff0055;">23</span><span style="color: #5D478B;">:</span><span style="color: #ff0055;">0</span><span style="color: #9F79EE;">&#93;</span> &nbsp; &nbsp; &nbsp;x2_imag<span style="color: #5D478B;">,</span><br />
&nbsp; &nbsp; <span style="color: #A52A2A; font-weight: bold;">input</span> <span style="color: #A52A2A; font-weight: bold;">signed</span> <span style="color: #9F79EE;">&#91;</span><span style="color: #ff0055;">23</span><span style="color: #5D478B;">:</span><span style="color: #ff0055;">0</span><span style="color: #9F79EE;">&#93;</span> &nbsp; &nbsp; &nbsp;x3_real<span style="color: #5D478B;">,</span><br />
&nbsp; &nbsp; <span style="color: #A52A2A; font-weight: bold;">input</span> <span style="color: #A52A2A; font-weight: bold;">signed</span> <span style="color: #9F79EE;">&#91;</span><span style="color: #ff0055;">23</span><span style="color: #5D478B;">:</span><span style="color: #ff0055;">0</span><span style="color: #9F79EE;">&#93;</span> &nbsp; &nbsp; &nbsp;x3_imag<span style="color: #5D478B;">,</span><br />
&nbsp; &nbsp; <span style="color: #A52A2A; font-weight: bold;">input</span> <span style="color: #A52A2A; font-weight: bold;">signed</span> <span style="color: #9F79EE;">&#91;</span><span style="color: #ff0055;">23</span><span style="color: #5D478B;">:</span><span style="color: #ff0055;">0</span><span style="color: #9F79EE;">&#93;</span> &nbsp; &nbsp; &nbsp;x4_real<span style="color: #5D478B;">,</span><br />
&nbsp; &nbsp; <span style="color: #A52A2A; font-weight: bold;">input</span> <span style="color: #A52A2A; font-weight: bold;">signed</span> <span style="color: #9F79EE;">&#91;</span><span style="color: #ff0055;">23</span><span style="color: #5D478B;">:</span><span style="color: #ff0055;">0</span><span style="color: #9F79EE;">&#93;</span> &nbsp; &nbsp; &nbsp;x4_imag<span style="color: #5D478B;">,</span><br />
&nbsp; &nbsp; <span style="color: #A52A2A; font-weight: bold;">input</span> <span style="color: #A52A2A; font-weight: bold;">signed</span> <span style="color: #9F79EE;">&#91;</span><span style="color: #ff0055;">23</span><span style="color: #5D478B;">:</span><span style="color: #ff0055;">0</span><span style="color: #9F79EE;">&#93;</span> &nbsp; &nbsp; &nbsp;x5_real<span style="color: #5D478B;">,</span><br />
&nbsp; &nbsp; <span style="color: #A52A2A; font-weight: bold;">input</span> <span style="color: #A52A2A; font-weight: bold;">signed</span> <span style="color: #9F79EE;">&#91;</span><span style="color: #ff0055;">23</span><span style="color: #5D478B;">:</span><span style="color: #ff0055;">0</span><span style="color: #9F79EE;">&#93;</span> &nbsp; &nbsp; &nbsp;x5_imag<span style="color: #5D478B;">,</span><br />
&nbsp; &nbsp; <span style="color: #A52A2A; font-weight: bold;">input</span> <span style="color: #A52A2A; font-weight: bold;">signed</span> <span style="color: #9F79EE;">&#91;</span><span style="color: #ff0055;">23</span><span style="color: #5D478B;">:</span><span style="color: #ff0055;">0</span><span style="color: #9F79EE;">&#93;</span> &nbsp; &nbsp; &nbsp;x6_real<span style="color: #5D478B;">,</span><br />
&nbsp; &nbsp; <span style="color: #A52A2A; font-weight: bold;">input</span> <span style="color: #A52A2A; font-weight: bold;">signed</span> <span style="color: #9F79EE;">&#91;</span><span style="color: #ff0055;">23</span><span style="color: #5D478B;">:</span><span style="color: #ff0055;">0</span><span style="color: #9F79EE;">&#93;</span> &nbsp; &nbsp; &nbsp;x6_imag<span style="color: #5D478B;">,</span><br />
&nbsp; &nbsp; <span style="color: #A52A2A; font-weight: bold;">input</span> <span style="color: #A52A2A; font-weight: bold;">signed</span> <span style="color: #9F79EE;">&#91;</span><span style="color: #ff0055;">23</span><span style="color: #5D478B;">:</span><span style="color: #ff0055;">0</span><span style="color: #9F79EE;">&#93;</span> &nbsp; &nbsp; &nbsp;x7_real<span style="color: #5D478B;">,</span><br />
&nbsp; &nbsp; <span style="color: #A52A2A; font-weight: bold;">input</span> <span style="color: #A52A2A; font-weight: bold;">signed</span> <span style="color: #9F79EE;">&#91;</span><span style="color: #ff0055;">23</span><span style="color: #5D478B;">:</span><span style="color: #ff0055;">0</span><span style="color: #9F79EE;">&#93;</span> &nbsp; &nbsp; &nbsp;x7_imag<span style="color: #5D478B;">,</span><br />
<br />
&nbsp; &nbsp; <span style="color: #A52A2A; font-weight: bold;">output</span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; valid<span style="color: #5D478B;">,</span><br />
&nbsp; &nbsp; <span style="color: #A52A2A; font-weight: bold;">output</span> <span style="color: #A52A2A; font-weight: bold;">signed</span> <span style="color: #9F79EE;">&#91;</span><span style="color: #ff0055;">23</span><span style="color: #5D478B;">:</span><span style="color: #ff0055;">0</span><span style="color: #9F79EE;">&#93;</span> &nbsp; &nbsp; y0_real<span style="color: #5D478B;">,</span><br />
&nbsp; &nbsp; <span style="color: #A52A2A; font-weight: bold;">output</span> <span style="color: #A52A2A; font-weight: bold;">signed</span> <span style="color: #9F79EE;">&#91;</span><span style="color: #ff0055;">23</span><span style="color: #5D478B;">:</span><span style="color: #ff0055;">0</span><span style="color: #9F79EE;">&#93;</span> &nbsp; &nbsp; y0_imag<span style="color: #5D478B;">,</span><br />
&nbsp; &nbsp; <span style="color: #A52A2A; font-weight: bold;">output</span> <span style="color: #A52A2A; font-weight: bold;">signed</span> <span style="color: #9F79EE;">&#91;</span><span style="color: #ff0055;">23</span><span style="color: #5D478B;">:</span><span style="color: #ff0055;">0</span><span style="color: #9F79EE;">&#93;</span> &nbsp; &nbsp; y1_real<span style="color: #5D478B;">,</span><br />
&nbsp; &nbsp; <span style="color: #A52A2A; font-weight: bold;">output</span> <span style="color: #A52A2A; font-weight: bold;">signed</span> <span style="color: #9F79EE;">&#91;</span><span style="color: #ff0055;">23</span><span style="color: #5D478B;">:</span><span style="color: #ff0055;">0</span><span style="color: #9F79EE;">&#93;</span> &nbsp; &nbsp; y1_imag<span style="color: #5D478B;">,</span><br />
&nbsp; &nbsp; <span style="color: #A52A2A; font-weight: bold;">output</span> <span style="color: #A52A2A; font-weight: bold;">signed</span> <span style="color: #9F79EE;">&#91;</span><span style="color: #ff0055;">23</span><span style="color: #5D478B;">:</span><span style="color: #ff0055;">0</span><span style="color: #9F79EE;">&#93;</span> &nbsp; &nbsp; y2_real<span style="color: #5D478B;">,</span><br />
&nbsp; &nbsp; <span style="color: #A52A2A; font-weight: bold;">output</span> <span style="color: #A52A2A; font-weight: bold;">signed</span> <span style="color: #9F79EE;">&#91;</span><span style="color: #ff0055;">23</span><span style="color: #5D478B;">:</span><span style="color: #ff0055;">0</span><span style="color: #9F79EE;">&#93;</span> &nbsp; &nbsp; y2_imag<span style="color: #5D478B;">,</span><br />
&nbsp; &nbsp; <span style="color: #A52A2A; font-weight: bold;">output</span> <span style="color: #A52A2A; font-weight: bold;">signed</span> <span style="color: #9F79EE;">&#91;</span><span style="color: #ff0055;">23</span><span style="color: #5D478B;">:</span><span style="color: #ff0055;">0</span><span style="color: #9F79EE;">&#93;</span> &nbsp; &nbsp; y3_real<span style="color: #5D478B;">,</span><br />
&nbsp; &nbsp; <span style="color: #A52A2A; font-weight: bold;">output</span> <span style="color: #A52A2A; font-weight: bold;">signed</span> <span style="color: #9F79EE;">&#91;</span><span style="color: #ff0055;">23</span><span style="color: #5D478B;">:</span><span style="color: #ff0055;">0</span><span style="color: #9F79EE;">&#93;</span> &nbsp; &nbsp; y3_imag<span style="color: #5D478B;">,</span><br />
&nbsp; &nbsp; <span style="color: #A52A2A; font-weight: bold;">output</span> <span style="color: #A52A2A; font-weight: bold;">signed</span> <span style="color: #9F79EE;">&#91;</span><span style="color: #ff0055;">23</span><span style="color: #5D478B;">:</span><span style="color: #ff0055;">0</span><span style="color: #9F79EE;">&#93;</span> &nbsp; &nbsp; y4_real<span style="color: #5D478B;">,</span><br />
&nbsp; &nbsp; <span style="color: #A52A2A; font-weight: bold;">output</span> <span style="color: #A52A2A; font-weight: bold;">signed</span> <span style="color: #9F79EE;">&#91;</span><span style="color: #ff0055;">23</span><span style="color: #5D478B;">:</span><span style="color: #ff0055;">0</span><span style="color: #9F79EE;">&#93;</span> &nbsp; &nbsp; y4_imag<span style="color: #5D478B;">,</span><br />
&nbsp; &nbsp; <span style="color: #A52A2A; font-weight: bold;">output</span> <span style="color: #A52A2A; font-weight: bold;">signed</span> <span style="color: #9F79EE;">&#91;</span><span style="color: #ff0055;">23</span><span style="color: #5D478B;">:</span><span style="color: #ff0055;">0</span><span style="color: #9F79EE;">&#93;</span> &nbsp; &nbsp; y5_real<span style="color: #5D478B;">,</span><br />
&nbsp; &nbsp; <span style="color: #A52A2A; font-weight: bold;">output</span> <span style="color: #A52A2A; font-weight: bold;">signed</span> <span style="color: #9F79EE;">&#91;</span><span style="color: #ff0055;">23</span><span style="color: #5D478B;">:</span><span style="color: #ff0055;">0</span><span style="color: #9F79EE;">&#93;</span> &nbsp; &nbsp; y5_imag<span style="color: #5D478B;">,</span><br />
&nbsp; &nbsp; <span style="color: #A52A2A; font-weight: bold;">output</span> <span style="color: #A52A2A; font-weight: bold;">signed</span> <span style="color: #9F79EE;">&#91;</span><span style="color: #ff0055;">23</span><span style="color: #5D478B;">:</span><span style="color: #ff0055;">0</span><span style="color: #9F79EE;">&#93;</span> &nbsp; &nbsp; y6_real<span style="color: #5D478B;">,</span><br />
&nbsp; &nbsp; <span style="color: #A52A2A; font-weight: bold;">output</span> <span style="color: #A52A2A; font-weight: bold;">signed</span> <span style="color: #9F79EE;">&#91;</span><span style="color: #ff0055;">23</span><span style="color: #5D478B;">:</span><span style="color: #ff0055;">0</span><span style="color: #9F79EE;">&#93;</span> &nbsp; &nbsp; y6_imag<span style="color: #5D478B;">,</span><br />
&nbsp; &nbsp; <span style="color: #A52A2A; font-weight: bold;">output</span> <span style="color: #A52A2A; font-weight: bold;">signed</span> <span style="color: #9F79EE;">&#91;</span><span style="color: #ff0055;">23</span><span style="color: #5D478B;">:</span><span style="color: #ff0055;">0</span><span style="color: #9F79EE;">&#93;</span> &nbsp; &nbsp; y7_real<span style="color: #5D478B;">,</span><br />
&nbsp; &nbsp; <span style="color: #A52A2A; font-weight: bold;">output</span> <span style="color: #A52A2A; font-weight: bold;">signed</span> <span style="color: #9F79EE;">&#91;</span><span style="color: #ff0055;">23</span><span style="color: #5D478B;">:</span><span style="color: #ff0055;">0</span><span style="color: #9F79EE;">&#93;</span> &nbsp; &nbsp; y7_imag<br />
&nbsp; &nbsp; <span style="color: #9F79EE;">&#41;</span><span style="color: #5D478B;">;</span><br />
<br />
&nbsp; &nbsp; <span style="color: #00008B; font-style: italic;">//operating data</span><br />
&nbsp; &nbsp; <span style="color: #A52A2A; font-weight: bold;">wire</span> <span style="color: #A52A2A; font-weight: bold;">signed</span> <span style="color: #9F79EE;">&#91;</span><span style="color: #ff0055;">23</span><span style="color: #5D478B;">:</span><span style="color: #ff0055;">0</span><span style="color: #9F79EE;">&#93;</span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; xm_real <span style="color: #9F79EE;">&#91;</span><span style="color: #ff0055;">3</span><span style="color: #5D478B;">:</span><span style="color: #ff0055;">0</span><span style="color: #9F79EE;">&#93;</span> <span style="color: #9F79EE;">&#91;</span><span style="color: #ff0055;">7</span><span style="color: #5D478B;">:</span><span style="color: #ff0055;">0</span><span style="color: #9F79EE;">&#93;</span><span style="color: #5D478B;">;</span><br />
&nbsp; &nbsp; <span style="color: #A52A2A; font-weight: bold;">wire</span> <span style="color: #A52A2A; font-weight: bold;">signed</span> <span style="color: #9F79EE;">&#91;</span><span style="color: #ff0055;">23</span><span style="color: #5D478B;">:</span><span style="color: #ff0055;">0</span><span style="color: #9F79EE;">&#93;</span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; xm_imag <span style="color: #9F79EE;">&#91;</span><span style="color: #ff0055;">3</span><span style="color: #5D478B;">:</span><span style="color: #ff0055;">0</span><span style="color: #9F79EE;">&#93;</span> <span style="color: #9F79EE;">&#91;</span><span style="color: #ff0055;">7</span><span style="color: #5D478B;">:</span><span style="color: #ff0055;">0</span><span style="color: #9F79EE;">&#93;</span><span style="color: #5D478B;">;</span><br />
&nbsp; &nbsp; <span style="color: #A52A2A; font-weight: bold;">wire</span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; en_connect <span style="color: #9F79EE;">&#91;</span><span style="color: #ff0055;">15</span><span style="color: #5D478B;">:</span><span style="color: #ff0055;">0</span><span style="color: #9F79EE;">&#93;</span> <span style="color: #5D478B;">;</span><br />
&nbsp; &nbsp; <span style="color: #A52A2A; font-weight: bold;">assign</span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; en_connect<span style="color: #9F79EE;">&#91;</span><span style="color: #ff0055;">0</span><span style="color: #9F79EE;">&#93;</span> <span style="color: #5D478B;">=</span> en<span style="color: #5D478B;">;</span><br />
&nbsp; &nbsp; <span style="color: #A52A2A; font-weight: bold;">assign</span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; en_connect<span style="color: #9F79EE;">&#91;</span><span style="color: #ff0055;">1</span><span style="color: #9F79EE;">&#93;</span> <span style="color: #5D478B;">=</span> en<span style="color: #5D478B;">;</span><br />
&nbsp; &nbsp; <span style="color: #A52A2A; font-weight: bold;">assign</span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; en_connect<span style="color: #9F79EE;">&#91;</span><span style="color: #ff0055;">2</span><span style="color: #9F79EE;">&#93;</span> <span style="color: #5D478B;">=</span> en<span style="color: #5D478B;">;</span><br />
&nbsp; &nbsp; <span style="color: #A52A2A; font-weight: bold;">assign</span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; en_connect<span style="color: #9F79EE;">&#91;</span><span style="color: #ff0055;">3</span><span style="color: #9F79EE;">&#93;</span> <span style="color: #5D478B;">=</span> en<span style="color: #5D478B;">;</span><br />
<br />
&nbsp; &nbsp; <span style="color: #00008B; font-style: italic;">//factor, multiplied by 0x2000</span><br />
&nbsp; &nbsp; <span style="color: #A52A2A; font-weight: bold;">wire</span> <span style="color: #A52A2A; font-weight: bold;">signed</span> <span style="color: #9F79EE;">&#91;</span><span style="color: #ff0055;">15</span><span style="color: #5D478B;">:</span><span style="color: #ff0055;">0</span><span style="color: #9F79EE;">&#93;</span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; factor_real <span style="color: #9F79EE;">&#91;</span><span style="color: #ff0055;">3</span><span style="color: #5D478B;">:</span><span style="color: #ff0055;">0</span><span style="color: #9F79EE;">&#93;</span> <span style="color: #5D478B;">;</span><br />
&nbsp; &nbsp; <span style="color: #A52A2A; font-weight: bold;">wire</span> <span style="color: #A52A2A; font-weight: bold;">signed</span> <span style="color: #9F79EE;">&#91;</span><span style="color: #ff0055;">15</span><span style="color: #5D478B;">:</span><span style="color: #ff0055;">0</span><span style="color: #9F79EE;">&#93;</span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; factor_imag <span style="color: #9F79EE;">&#91;</span><span style="color: #ff0055;">3</span><span style="color: #5D478B;">:</span><span style="color: #ff0055;">0</span><span style="color: #9F79EE;">&#93;</span><span style="color: #5D478B;">;</span><br />
&nbsp; &nbsp; <span style="color: #A52A2A; font-weight: bold;">assign</span> factor_real<span style="color: #9F79EE;">&#91;</span><span style="color: #ff0055;">0</span><span style="color: #9F79EE;">&#93;</span> &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #5D478B;">=</span> <span style="color: #ff0055;">1</span><span style="color: #ff0055;">6'h2000</span><span style="color: #5D478B;">;</span> <span style="color: #00008B; font-style: italic;">//1</span><br />
&nbsp; &nbsp; <span style="color: #A52A2A; font-weight: bold;">assign</span> factor_imag<span style="color: #9F79EE;">&#91;</span><span style="color: #ff0055;">0</span><span style="color: #9F79EE;">&#93;</span> &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #5D478B;">=</span> <span style="color: #ff0055;">1</span><span style="color: #ff0055;">6'h0000</span><span style="color: #5D478B;">;</span> <span style="color: #00008B; font-style: italic;">//0</span><br />
&nbsp; &nbsp; <span style="color: #A52A2A; font-weight: bold;">assign</span> factor_real<span style="color: #9F79EE;">&#91;</span><span style="color: #ff0055;">1</span><span style="color: #9F79EE;">&#93;</span> &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #5D478B;">=</span> <span style="color: #ff0055;">1</span><span style="color: #ff0055;">6'h16a0</span><span style="color: #5D478B;">;</span> <span style="color: #00008B; font-style: italic;">//sqrt(2)/2</span><br />
&nbsp; &nbsp; <span style="color: #A52A2A; font-weight: bold;">assign</span> factor_imag<span style="color: #9F79EE;">&#91;</span><span style="color: #ff0055;">1</span><span style="color: #9F79EE;">&#93;</span> &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #5D478B;">=</span> <span style="color: #ff0055;">1</span><span style="color: #ff0055;">6'he95f</span><span style="color: #5D478B;">;</span> <span style="color: #00008B; font-style: italic;">//-sqrt(2)/2</span><br />
&nbsp; &nbsp; <span style="color: #A52A2A; font-weight: bold;">assign</span> factor_real<span style="color: #9F79EE;">&#91;</span><span style="color: #ff0055;">2</span><span style="color: #9F79EE;">&#93;</span> &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #5D478B;">=</span> <span style="color: #ff0055;">1</span><span style="color: #ff0055;">6'h0000</span><span style="color: #5D478B;">;</span> <span style="color: #00008B; font-style: italic;">//0</span><br />
&nbsp; &nbsp; <span style="color: #A52A2A; font-weight: bold;">assign</span> factor_imag<span style="color: #9F79EE;">&#91;</span><span style="color: #ff0055;">2</span><span style="color: #9F79EE;">&#93;</span> &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #5D478B;">=</span> <span style="color: #ff0055;">1</span><span style="color: #ff0055;">6'he000</span><span style="color: #5D478B;">;</span> <span style="color: #00008B; font-style: italic;">//-1</span><br />
&nbsp; &nbsp; <span style="color: #A52A2A; font-weight: bold;">assign</span> factor_real<span style="color: #9F79EE;">&#91;</span><span style="color: #ff0055;">3</span><span style="color: #9F79EE;">&#93;</span> &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #5D478B;">=</span> <span style="color: #ff0055;">1</span><span style="color: #ff0055;">6'he95f</span><span style="color: #5D478B;">;</span> <span style="color: #00008B; font-style: italic;">//-sqrt(2)/2</span><br />
&nbsp; &nbsp; <span style="color: #A52A2A; font-weight: bold;">assign</span> factor_imag<span style="color: #9F79EE;">&#91;</span><span style="color: #ff0055;">3</span><span style="color: #9F79EE;">&#93;</span> &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #5D478B;">=</span> <span style="color: #ff0055;">1</span><span style="color: #ff0055;">6'he95f</span><span style="color: #5D478B;">;</span> <span style="color: #00008B; font-style: italic;">//-sqrt(2)/2</span><br />
<br />
&nbsp; &nbsp; <span style="color: #00008B; font-style: italic;">//输入初始化，和码位有关倒置</span><br />
&nbsp; &nbsp; <span style="color: #A52A2A; font-weight: bold;">assign</span> xm_real<span style="color: #9F79EE;">&#91;</span><span style="color: #ff0055;">0</span><span style="color: #9F79EE;">&#93;</span><span style="color: #9F79EE;">&#91;</span><span style="color: #ff0055;">0</span><span style="color: #9F79EE;">&#93;</span> <span style="color: #5D478B;">=</span> x0_real<span style="color: #5D478B;">;</span><br />
&nbsp; &nbsp; <span style="color: #A52A2A; font-weight: bold;">assign</span> xm_real<span style="color: #9F79EE;">&#91;</span><span style="color: #ff0055;">0</span><span style="color: #9F79EE;">&#93;</span><span style="color: #9F79EE;">&#91;</span><span style="color: #ff0055;">1</span><span style="color: #9F79EE;">&#93;</span> <span style="color: #5D478B;">=</span> x4_real<span style="color: #5D478B;">;</span><br />
&nbsp; &nbsp; <span style="color: #A52A2A; font-weight: bold;">assign</span> xm_real<span style="color: #9F79EE;">&#91;</span><span style="color: #ff0055;">0</span><span style="color: #9F79EE;">&#93;</span><span style="color: #9F79EE;">&#91;</span><span style="color: #ff0055;">2</span><span style="color: #9F79EE;">&#93;</span> <span style="color: #5D478B;">=</span> x2_real<span style="color: #5D478B;">;</span><br />
&nbsp; &nbsp; <span style="color: #A52A2A; font-weight: bold;">assign</span> xm_real<span style="color: #9F79EE;">&#91;</span><span style="color: #ff0055;">0</span><span style="color: #9F79EE;">&#93;</span><span style="color: #9F79EE;">&#91;</span><span style="color: #ff0055;">3</span><span style="color: #9F79EE;">&#93;</span> <span style="color: #5D478B;">=</span> x6_real<span style="color: #5D478B;">;</span><br />
&nbsp; &nbsp; <span style="color: #A52A2A; font-weight: bold;">assign</span> xm_real<span style="color: #9F79EE;">&#91;</span><span style="color: #ff0055;">0</span><span style="color: #9F79EE;">&#93;</span><span style="color: #9F79EE;">&#91;</span><span style="color: #ff0055;">4</span><span style="color: #9F79EE;">&#93;</span> <span style="color: #5D478B;">=</span> x1_real<span style="color: #5D478B;">;</span><br />
&nbsp; &nbsp; <span style="color: #A52A2A; font-weight: bold;">assign</span> xm_real<span style="color: #9F79EE;">&#91;</span><span style="color: #ff0055;">0</span><span style="color: #9F79EE;">&#93;</span><span style="color: #9F79EE;">&#91;</span><span style="color: #ff0055;">5</span><span style="color: #9F79EE;">&#93;</span> <span style="color: #5D478B;">=</span> x5_real<span style="color: #5D478B;">;</span><br />
&nbsp; &nbsp; <span style="color: #A52A2A; font-weight: bold;">assign</span> xm_real<span style="color: #9F79EE;">&#91;</span><span style="color: #ff0055;">0</span><span style="color: #9F79EE;">&#93;</span><span style="color: #9F79EE;">&#91;</span><span style="color: #ff0055;">6</span><span style="color: #9F79EE;">&#93;</span> <span style="color: #5D478B;">=</span> x3_real<span style="color: #5D478B;">;</span><br />
&nbsp; &nbsp; <span style="color: #A52A2A; font-weight: bold;">assign</span> xm_real<span style="color: #9F79EE;">&#91;</span><span style="color: #ff0055;">0</span><span style="color: #9F79EE;">&#93;</span><span style="color: #9F79EE;">&#91;</span><span style="color: #ff0055;">7</span><span style="color: #9F79EE;">&#93;</span> <span style="color: #5D478B;">=</span> x7_real<span style="color: #5D478B;">;</span><br />
&nbsp; &nbsp; <span style="color: #A52A2A; font-weight: bold;">assign</span> xm_imag<span style="color: #9F79EE;">&#91;</span><span style="color: #ff0055;">0</span><span style="color: #9F79EE;">&#93;</span><span style="color: #9F79EE;">&#91;</span><span style="color: #ff0055;">0</span><span style="color: #9F79EE;">&#93;</span> <span style="color: #5D478B;">=</span> x0_imag<span style="color: #5D478B;">;</span><br />
&nbsp; &nbsp; <span style="color: #A52A2A; font-weight: bold;">assign</span> xm_imag<span style="color: #9F79EE;">&#91;</span><span style="color: #ff0055;">0</span><span style="color: #9F79EE;">&#93;</span><span style="color: #9F79EE;">&#91;</span><span style="color: #ff0055;">1</span><span style="color: #9F79EE;">&#93;</span> <span style="color: #5D478B;">=</span> x4_imag<span style="color: #5D478B;">;</span><br />
&nbsp; &nbsp; <span style="color: #A52A2A; font-weight: bold;">assign</span> xm_imag<span style="color: #9F79EE;">&#91;</span><span style="color: #ff0055;">0</span><span style="color: #9F79EE;">&#93;</span><span style="color: #9F79EE;">&#91;</span><span style="color: #ff0055;">2</span><span style="color: #9F79EE;">&#93;</span> <span style="color: #5D478B;">=</span> x2_imag<span style="color: #5D478B;">;</span><br />
&nbsp; &nbsp; <span style="color: #A52A2A; font-weight: bold;">assign</span> xm_imag<span style="color: #9F79EE;">&#91;</span><span style="color: #ff0055;">0</span><span style="color: #9F79EE;">&#93;</span><span style="color: #9F79EE;">&#91;</span><span style="color: #ff0055;">3</span><span style="color: #9F79EE;">&#93;</span> <span style="color: #5D478B;">=</span> x6_imag<span style="color: #5D478B;">;</span><br />
&nbsp; &nbsp; <span style="color: #A52A2A; font-weight: bold;">assign</span> xm_imag<span style="color: #9F79EE;">&#91;</span><span style="color: #ff0055;">0</span><span style="color: #9F79EE;">&#93;</span><span style="color: #9F79EE;">&#91;</span><span style="color: #ff0055;">4</span><span style="color: #9F79EE;">&#93;</span> <span style="color: #5D478B;">=</span> x1_imag<span style="color: #5D478B;">;</span><br />
&nbsp; &nbsp; <span style="color: #A52A2A; font-weight: bold;">assign</span> xm_imag<span style="color: #9F79EE;">&#91;</span><span style="color: #ff0055;">0</span><span style="color: #9F79EE;">&#93;</span><span style="color: #9F79EE;">&#91;</span><span style="color: #ff0055;">5</span><span style="color: #9F79EE;">&#93;</span> <span style="color: #5D478B;">=</span> x5_imag<span style="color: #5D478B;">;</span><br />
&nbsp; &nbsp; <span style="color: #A52A2A; font-weight: bold;">assign</span> xm_imag<span style="color: #9F79EE;">&#91;</span><span style="color: #ff0055;">0</span><span style="color: #9F79EE;">&#93;</span><span style="color: #9F79EE;">&#91;</span><span style="color: #ff0055;">6</span><span style="color: #9F79EE;">&#93;</span> <span style="color: #5D478B;">=</span> x3_imag<span style="color: #5D478B;">;</span><br />
&nbsp; &nbsp; <span style="color: #A52A2A; font-weight: bold;">assign</span> xm_imag<span style="color: #9F79EE;">&#91;</span><span style="color: #ff0055;">0</span><span style="color: #9F79EE;">&#93;</span><span style="color: #9F79EE;">&#91;</span><span style="color: #ff0055;">7</span><span style="color: #9F79EE;">&#93;</span> <span style="color: #5D478B;">=</span> x7_imag<span style="color: #5D478B;">;</span><br />
<br />
&nbsp; &nbsp; <span style="color: #00008B; font-style: italic;">//butter instantiaiton</span><br />
&nbsp; &nbsp; <span style="color: #00008B; font-style: italic;">//integer &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;index[11:0] ;</span><br />
&nbsp; &nbsp; <span style="color: #A52A2A; font-weight: bold;">genvar</span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; m<span style="color: #5D478B;">,</span> k<span style="color: #5D478B;">;</span><br />
&nbsp; &nbsp; <span style="color: #A52A2A; font-weight: bold;">generate</span><br />
&nbsp; &nbsp; <span style="color: #00008B; font-style: italic;">//3 stage</span><br />
&nbsp; &nbsp; <span style="color: #A52A2A; font-weight: bold;">for</span><span style="color: #9F79EE;">&#40;</span>m<span style="color: #5D478B;">=</span><span style="color: #ff0055;">0</span><span style="color: #5D478B;">;</span> m<span style="color: #5D478B;">&lt;=</span><span style="color: #ff0055;">2</span><span style="color: #5D478B;">;</span> m<span style="color: #5D478B;">=</span>m<span style="color: #5D478B;">+</span><span style="color: #ff0055;">1</span><span style="color: #9F79EE;">&#41;</span> <span style="color: #A52A2A; font-weight: bold;">begin</span><span style="color: #5D478B;">:</span> stage<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #A52A2A; font-weight: bold;">for</span> <span style="color: #9F79EE;">&#40;</span>k<span style="color: #5D478B;">=</span><span style="color: #ff0055;">0</span><span style="color: #5D478B;">;</span> k<span style="color: #5D478B;">&lt;=</span><span style="color: #ff0055;">3</span><span style="color: #5D478B;">;</span> k<span style="color: #5D478B;">=</span>k<span style="color: #5D478B;">+</span><span style="color: #ff0055;">1</span><span style="color: #9F79EE;">&#41;</span> <span style="color: #A52A2A; font-weight: bold;">begin</span><span style="color: #5D478B;">:</span> unit<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; butterfly &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; u_butter<span style="color: #9F79EE;">&#40;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;.clk &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #9F79EE;">&#40;</span>clk &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #9F79EE;">&#41;</span> <span style="color: #5D478B;">,</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;.rstn &nbsp; &nbsp; &nbsp; <span style="color: #9F79EE;">&#40;</span>rstn &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #9F79EE;">&#41;</span> <span style="color: #5D478B;">,</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;.en &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #9F79EE;">&#40;</span>en_connect<span style="color: #9F79EE;">&#91;</span>m<span style="color: #5D478B;">*</span><span style="color: #ff0055;">4</span> <span style="color: #5D478B;">+</span> k<span style="color: #9F79EE;">&#93;</span> <span style="color: #9F79EE;">&#41;</span> <span style="color: #5D478B;">,</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #00008B; font-style: italic;">//是否再组内？组编号+组内编号：下组编号+新组内编号</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;.xp_real &nbsp; &nbsp;<span style="color: #9F79EE;">&#40;</span>xm_real<span style="color: #9F79EE;">&#91;</span> m <span style="color: #9F79EE;">&#93;</span> <span style="color: #9F79EE;">&#91;</span>k<span style="color: #9F79EE;">&#91;</span>m<span style="color: #5D478B;">:</span><span style="color: #ff0055;">0</span><span style="color: #9F79EE;">&#93;</span> <span style="color: #5D478B;">&lt;</span> <span style="color: #9F79EE;">&#40;</span><span style="color: #ff0055;">1</span><span style="color: #5D478B;">&lt;&lt;</span>m<span style="color: #9F79EE;">&#41;</span> <span style="color: #5D478B;">?</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #9F79EE;">&#40;</span>k<span style="color: #9F79EE;">&#91;</span><span style="color: #ff0055;">3</span><span style="color: #5D478B;">:</span>m<span style="color: #9F79EE;">&#93;</span> <span style="color: #5D478B;">&lt;&lt;</span> <span style="color: #9F79EE;">&#40;</span>m<span style="color: #5D478B;">+</span><span style="color: #ff0055;">1</span><span style="color: #9F79EE;">&#41;</span><span style="color: #9F79EE;">&#41;</span> <span style="color: #5D478B;">+</span> k<span style="color: #9F79EE;">&#91;</span>m<span style="color: #5D478B;">:</span><span style="color: #ff0055;">0</span><span style="color: #9F79EE;">&#93;</span> <span style="color: #5D478B;">:</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #9F79EE;">&#40;</span>k<span style="color: #9F79EE;">&#91;</span><span style="color: #ff0055;">3</span><span style="color: #5D478B;">:</span>m<span style="color: #9F79EE;">&#93;</span> <span style="color: #5D478B;">&lt;&lt;</span> <span style="color: #9F79EE;">&#40;</span>m<span style="color: #5D478B;">+</span><span style="color: #ff0055;">1</span><span style="color: #9F79EE;">&#41;</span><span style="color: #9F79EE;">&#41;</span> <span style="color: #5D478B;">+</span> <span style="color: #9F79EE;">&#40;</span>k<span style="color: #9F79EE;">&#91;</span>m<span style="color: #5D478B;">:</span><span style="color: #ff0055;">0</span><span style="color: #9F79EE;">&#93;</span><span style="color: #5D478B;">-</span><span style="color: #9F79EE;">&#40;</span><span style="color: #ff0055;">1</span><span style="color: #5D478B;">&lt;&lt;</span>m<span style="color: #9F79EE;">&#41;</span><span style="color: #9F79EE;">&#41;</span><span style="color: #9F79EE;">&#93;</span> <span style="color: #9F79EE;">&#41;</span><span style="color: #5D478B;">,</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;.xp_imag &nbsp; &nbsp;<span style="color: #9F79EE;">&#40;</span>xm_imag<span style="color: #9F79EE;">&#91;</span> m <span style="color: #9F79EE;">&#93;</span> <span style="color: #9F79EE;">&#91;</span>k<span style="color: #9F79EE;">&#91;</span>m<span style="color: #5D478B;">:</span><span style="color: #ff0055;">0</span><span style="color: #9F79EE;">&#93;</span> <span style="color: #5D478B;">&lt;</span> <span style="color: #9F79EE;">&#40;</span><span style="color: #ff0055;">1</span><span style="color: #5D478B;">&lt;&lt;</span>m<span style="color: #9F79EE;">&#41;</span> <span style="color: #5D478B;">?</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #9F79EE;">&#40;</span>k<span style="color: #9F79EE;">&#91;</span><span style="color: #ff0055;">3</span><span style="color: #5D478B;">:</span>m<span style="color: #9F79EE;">&#93;</span> <span style="color: #5D478B;">&lt;&lt;</span> <span style="color: #9F79EE;">&#40;</span>m<span style="color: #5D478B;">+</span><span style="color: #ff0055;">1</span><span style="color: #9F79EE;">&#41;</span><span style="color: #9F79EE;">&#41;</span> <span style="color: #5D478B;">+</span> k<span style="color: #9F79EE;">&#91;</span>m<span style="color: #5D478B;">:</span><span style="color: #ff0055;">0</span><span style="color: #9F79EE;">&#93;</span> <span style="color: #5D478B;">:</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #9F79EE;">&#40;</span>k<span style="color: #9F79EE;">&#91;</span><span style="color: #ff0055;">3</span><span style="color: #5D478B;">:</span>m<span style="color: #9F79EE;">&#93;</span> <span style="color: #5D478B;">&lt;&lt;</span> <span style="color: #9F79EE;">&#40;</span>m<span style="color: #5D478B;">+</span><span style="color: #ff0055;">1</span><span style="color: #9F79EE;">&#41;</span><span style="color: #9F79EE;">&#41;</span> <span style="color: #5D478B;">+</span> <span style="color: #9F79EE;">&#40;</span>k<span style="color: #9F79EE;">&#91;</span>m<span style="color: #5D478B;">:</span><span style="color: #ff0055;">0</span><span style="color: #9F79EE;">&#93;</span><span style="color: #5D478B;">-</span><span style="color: #9F79EE;">&#40;</span><span style="color: #ff0055;">1</span><span style="color: #5D478B;">&lt;&lt;</span>m<span style="color: #9F79EE;">&#41;</span><span style="color: #9F79EE;">&#41;</span><span style="color: #9F79EE;">&#93;</span> <span style="color: #9F79EE;">&#41;</span><span style="color: #5D478B;">,</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;.xq_real &nbsp; &nbsp;<span style="color: #9F79EE;">&#40;</span>xm_real<span style="color: #9F79EE;">&#91;</span> m <span style="color: #9F79EE;">&#93;</span> <span style="color: #9F79EE;">&#91;</span><span style="color: #9F79EE;">&#40;</span>k<span style="color: #9F79EE;">&#91;</span>m<span style="color: #5D478B;">:</span><span style="color: #ff0055;">0</span><span style="color: #9F79EE;">&#93;</span> <span style="color: #5D478B;">&lt;</span> <span style="color: #9F79EE;">&#40;</span><span style="color: #ff0055;">1</span><span style="color: #5D478B;">&lt;&lt;</span>m<span style="color: #9F79EE;">&#41;</span> <span style="color: #5D478B;">?</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #9F79EE;">&#40;</span>k<span style="color: #9F79EE;">&#91;</span><span style="color: #ff0055;">3</span><span style="color: #5D478B;">:</span>m<span style="color: #9F79EE;">&#93;</span> <span style="color: #5D478B;">&lt;&lt;</span> <span style="color: #9F79EE;">&#40;</span>m<span style="color: #5D478B;">+</span><span style="color: #ff0055;">1</span><span style="color: #9F79EE;">&#41;</span><span style="color: #9F79EE;">&#41;</span> <span style="color: #5D478B;">+</span> k<span style="color: #9F79EE;">&#91;</span>m<span style="color: #5D478B;">:</span><span style="color: #ff0055;">0</span><span style="color: #9F79EE;">&#93;</span> <span style="color: #5D478B;">:</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #9F79EE;">&#40;</span>k<span style="color: #9F79EE;">&#91;</span><span style="color: #ff0055;">3</span><span style="color: #5D478B;">:</span>m<span style="color: #9F79EE;">&#93;</span> <span style="color: #5D478B;">&lt;&lt;</span> <span style="color: #9F79EE;">&#40;</span>m<span style="color: #5D478B;">+</span><span style="color: #ff0055;">1</span><span style="color: #9F79EE;">&#41;</span><span style="color: #9F79EE;">&#41;</span> <span style="color: #5D478B;">+</span> <span style="color: #9F79EE;">&#40;</span>k<span style="color: #9F79EE;">&#91;</span>m<span style="color: #5D478B;">:</span><span style="color: #ff0055;">0</span><span style="color: #9F79EE;">&#93;</span><span style="color: #5D478B;">-</span><span style="color: #9F79EE;">&#40;</span><span style="color: #ff0055;">1</span><span style="color: #5D478B;">&lt;&lt;</span>m<span style="color: #9F79EE;">&#41;</span><span style="color: #9F79EE;">&#41;</span><span style="color: #9F79EE;">&#41;</span> <span style="color: #5D478B;">+</span> <span style="color: #9F79EE;">&#40;</span><span style="color: #ff0055;">1</span><span style="color: #5D478B;">&lt;&lt;</span>m<span style="color: #9F79EE;">&#41;</span> <span style="color: #9F79EE;">&#93;</span><span style="color: #9F79EE;">&#41;</span><span style="color: #5D478B;">,</span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #00008B; font-style: italic;">//增加蝶形单元两个输入端口间距离</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;.xq_imag &nbsp; &nbsp;<span style="color: #9F79EE;">&#40;</span>xm_imag<span style="color: #9F79EE;">&#91;</span> m <span style="color: #9F79EE;">&#93;</span> <span style="color: #9F79EE;">&#91;</span><span style="color: #9F79EE;">&#40;</span>k<span style="color: #9F79EE;">&#91;</span>m<span style="color: #5D478B;">:</span><span style="color: #ff0055;">0</span><span style="color: #9F79EE;">&#93;</span> <span style="color: #5D478B;">&lt;</span> <span style="color: #9F79EE;">&#40;</span><span style="color: #ff0055;">1</span><span style="color: #5D478B;">&lt;&lt;</span>m<span style="color: #9F79EE;">&#41;</span> <span style="color: #5D478B;">?</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #9F79EE;">&#40;</span>k<span style="color: #9F79EE;">&#91;</span><span style="color: #ff0055;">3</span><span style="color: #5D478B;">:</span>m<span style="color: #9F79EE;">&#93;</span> <span style="color: #5D478B;">&lt;&lt;</span> <span style="color: #9F79EE;">&#40;</span>m<span style="color: #5D478B;">+</span><span style="color: #ff0055;">1</span><span style="color: #9F79EE;">&#41;</span><span style="color: #9F79EE;">&#41;</span> <span style="color: #5D478B;">+</span> k<span style="color: #9F79EE;">&#91;</span>m<span style="color: #5D478B;">:</span><span style="color: #ff0055;">0</span><span style="color: #9F79EE;">&#93;</span> <span style="color: #5D478B;">:</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #9F79EE;">&#40;</span>k<span style="color: #9F79EE;">&#91;</span><span style="color: #ff0055;">3</span><span style="color: #5D478B;">:</span>m<span style="color: #9F79EE;">&#93;</span> <span style="color: #5D478B;">&lt;&lt;</span> <span style="color: #9F79EE;">&#40;</span>m<span style="color: #5D478B;">+</span><span style="color: #ff0055;">1</span><span style="color: #9F79EE;">&#41;</span><span style="color: #9F79EE;">&#41;</span> <span style="color: #5D478B;">+</span> <span style="color: #9F79EE;">&#40;</span>k<span style="color: #9F79EE;">&#91;</span>m<span style="color: #5D478B;">:</span><span style="color: #ff0055;">0</span><span style="color: #9F79EE;">&#93;</span><span style="color: #5D478B;">-</span><span style="color: #9F79EE;">&#40;</span><span style="color: #ff0055;">1</span><span style="color: #5D478B;">&lt;&lt;</span>m<span style="color: #9F79EE;">&#41;</span><span style="color: #9F79EE;">&#41;</span><span style="color: #9F79EE;">&#41;</span> <span style="color: #5D478B;">+</span> <span style="color: #9F79EE;">&#40;</span><span style="color: #ff0055;">1</span><span style="color: #5D478B;">&lt;&lt;</span>m<span style="color: #9F79EE;">&#41;</span> <span style="color: #9F79EE;">&#93;</span><span style="color: #9F79EE;">&#41;</span><span style="color: #5D478B;">,</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;.factor_real<span style="color: #9F79EE;">&#40;</span>factor_real<span style="color: #9F79EE;">&#91;</span>k<span style="color: #9F79EE;">&#91;</span>m<span style="color: #5D478B;">:</span><span style="color: #ff0055;">0</span><span style="color: #9F79EE;">&#93;</span><span style="color: #5D478B;">&lt;</span><span style="color: #9F79EE;">&#40;</span><span style="color: #ff0055;">1</span><span style="color: #5D478B;">&lt;&lt;</span>m<span style="color: #9F79EE;">&#41;</span><span style="color: #5D478B;">?</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; k<span style="color: #9F79EE;">&#91;</span>m<span style="color: #5D478B;">:</span><span style="color: #ff0055;">0</span><span style="color: #9F79EE;">&#93;</span> <span style="color: #5D478B;">:</span> k<span style="color: #9F79EE;">&#91;</span>m<span style="color: #5D478B;">:</span><span style="color: #ff0055;">0</span><span style="color: #9F79EE;">&#93;</span><span style="color: #5D478B;">-</span><span style="color: #9F79EE;">&#40;</span><span style="color: #ff0055;">1</span><span style="color: #5D478B;">&lt;&lt;</span>m<span style="color: #9F79EE;">&#41;</span> <span style="color: #9F79EE;">&#93;</span><span style="color: #9F79EE;">&#41;</span><span style="color: #5D478B;">,</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;.factor_imag<span style="color: #9F79EE;">&#40;</span>factor_imag<span style="color: #9F79EE;">&#91;</span>k<span style="color: #9F79EE;">&#91;</span>m<span style="color: #5D478B;">:</span><span style="color: #ff0055;">0</span><span style="color: #9F79EE;">&#93;</span><span style="color: #5D478B;">&lt;</span><span style="color: #9F79EE;">&#40;</span><span style="color: #ff0055;">1</span><span style="color: #5D478B;">&lt;&lt;</span>m<span style="color: #9F79EE;">&#41;</span><span style="color: #5D478B;">?</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; k<span style="color: #9F79EE;">&#91;</span>m<span style="color: #5D478B;">:</span><span style="color: #ff0055;">0</span><span style="color: #9F79EE;">&#93;</span> <span style="color: #5D478B;">:</span> k<span style="color: #9F79EE;">&#91;</span>m<span style="color: #5D478B;">:</span><span style="color: #ff0055;">0</span><span style="color: #9F79EE;">&#93;</span><span style="color: #5D478B;">-</span><span style="color: #9F79EE;">&#40;</span><span style="color: #ff0055;">1</span><span style="color: #5D478B;">&lt;&lt;</span>m<span style="color: #9F79EE;">&#41;</span> <span style="color: #9F79EE;">&#93;</span><span style="color: #9F79EE;">&#41;</span><span style="color: #5D478B;">,</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #00008B; font-style: italic;">//output data</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;.valid &nbsp; &nbsp; &nbsp;<span style="color: #9F79EE;">&#40;</span>en_connect<span style="color: #9F79EE;">&#91;</span> <span style="color: #9F79EE;">&#40;</span>m<span style="color: #5D478B;">+</span><span style="color: #ff0055;">1</span><span style="color: #9F79EE;">&#41;</span><span style="color: #5D478B;">*</span><span style="color: #ff0055;">4</span> <span style="color: #5D478B;">+</span> k <span style="color: #9F79EE;">&#93;</span> &nbsp;<span style="color: #9F79EE;">&#41;</span><span style="color: #5D478B;">,</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;.yp_real &nbsp; &nbsp;<span style="color: #9F79EE;">&#40;</span>xm_real<span style="color: #9F79EE;">&#91;</span> m<span style="color: #5D478B;">+</span><span style="color: #ff0055;">1</span> <span style="color: #9F79EE;">&#93;</span><span style="color: #9F79EE;">&#91;</span>k<span style="color: #9F79EE;">&#91;</span>m<span style="color: #5D478B;">:</span><span style="color: #ff0055;">0</span><span style="color: #9F79EE;">&#93;</span> <span style="color: #5D478B;">&lt;</span> <span style="color: #9F79EE;">&#40;</span><span style="color: #ff0055;">1</span><span style="color: #5D478B;">&lt;&lt;</span>m<span style="color: #9F79EE;">&#41;</span> <span style="color: #5D478B;">?</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #9F79EE;">&#40;</span>k<span style="color: #9F79EE;">&#91;</span><span style="color: #ff0055;">3</span><span style="color: #5D478B;">:</span>m<span style="color: #9F79EE;">&#93;</span> <span style="color: #5D478B;">&lt;&lt;</span> <span style="color: #9F79EE;">&#40;</span>m<span style="color: #5D478B;">+</span><span style="color: #ff0055;">1</span><span style="color: #9F79EE;">&#41;</span><span style="color: #9F79EE;">&#41;</span> <span style="color: #5D478B;">+</span> k<span style="color: #9F79EE;">&#91;</span>m<span style="color: #5D478B;">:</span><span style="color: #ff0055;">0</span><span style="color: #9F79EE;">&#93;</span> <span style="color: #5D478B;">:</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #9F79EE;">&#40;</span>k<span style="color: #9F79EE;">&#91;</span><span style="color: #ff0055;">3</span><span style="color: #5D478B;">:</span>m<span style="color: #9F79EE;">&#93;</span> <span style="color: #5D478B;">&lt;&lt;</span> <span style="color: #9F79EE;">&#40;</span>m<span style="color: #5D478B;">+</span><span style="color: #ff0055;">1</span><span style="color: #9F79EE;">&#41;</span><span style="color: #9F79EE;">&#41;</span> <span style="color: #5D478B;">+</span> <span style="color: #9F79EE;">&#40;</span>k<span style="color: #9F79EE;">&#91;</span>m<span style="color: #5D478B;">:</span><span style="color: #ff0055;">0</span><span style="color: #9F79EE;">&#93;</span><span style="color: #5D478B;">-</span><span style="color: #9F79EE;">&#40;</span><span style="color: #ff0055;">1</span><span style="color: #5D478B;">&lt;&lt;</span>m<span style="color: #9F79EE;">&#41;</span><span style="color: #9F79EE;">&#41;</span><span style="color: #9F79EE;">&#93;</span> <span style="color: #9F79EE;">&#41;</span><span style="color: #5D478B;">,</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;.yp_imag &nbsp; &nbsp;<span style="color: #9F79EE;">&#40;</span>xm_imag<span style="color: #9F79EE;">&#91;</span> m<span style="color: #5D478B;">+</span><span style="color: #ff0055;">1</span> <span style="color: #9F79EE;">&#93;</span><span style="color: #9F79EE;">&#91;</span><span style="color: #9F79EE;">&#40;</span>k<span style="color: #9F79EE;">&#91;</span>m<span style="color: #5D478B;">:</span><span style="color: #ff0055;">0</span><span style="color: #9F79EE;">&#93;</span><span style="color: #9F79EE;">&#41;</span> <span style="color: #5D478B;">&lt;</span> <span style="color: #9F79EE;">&#40;</span><span style="color: #ff0055;">1</span><span style="color: #5D478B;">&lt;&lt;</span>m<span style="color: #9F79EE;">&#41;</span> <span style="color: #5D478B;">?</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #9F79EE;">&#40;</span>k<span style="color: #9F79EE;">&#91;</span><span style="color: #ff0055;">3</span><span style="color: #5D478B;">:</span>m<span style="color: #9F79EE;">&#93;</span> <span style="color: #5D478B;">&lt;&lt;</span> <span style="color: #9F79EE;">&#40;</span>m<span style="color: #5D478B;">+</span><span style="color: #ff0055;">1</span><span style="color: #9F79EE;">&#41;</span><span style="color: #9F79EE;">&#41;</span> <span style="color: #5D478B;">+</span> k<span style="color: #9F79EE;">&#91;</span>m<span style="color: #5D478B;">:</span><span style="color: #ff0055;">0</span><span style="color: #9F79EE;">&#93;</span> <span style="color: #5D478B;">:</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #9F79EE;">&#40;</span>k<span style="color: #9F79EE;">&#91;</span><span style="color: #ff0055;">3</span><span style="color: #5D478B;">:</span>m<span style="color: #9F79EE;">&#93;</span> <span style="color: #5D478B;">&lt;&lt;</span> <span style="color: #9F79EE;">&#40;</span>m<span style="color: #5D478B;">+</span><span style="color: #ff0055;">1</span><span style="color: #9F79EE;">&#41;</span><span style="color: #9F79EE;">&#41;</span> <span style="color: #5D478B;">+</span> <span style="color: #9F79EE;">&#40;</span>k<span style="color: #9F79EE;">&#91;</span>m<span style="color: #5D478B;">:</span><span style="color: #ff0055;">0</span><span style="color: #9F79EE;">&#93;</span><span style="color: #5D478B;">-</span><span style="color: #9F79EE;">&#40;</span><span style="color: #ff0055;">1</span><span style="color: #5D478B;">&lt;&lt;</span>m<span style="color: #9F79EE;">&#41;</span><span style="color: #9F79EE;">&#41;</span><span style="color: #9F79EE;">&#93;</span> <span style="color: #9F79EE;">&#41;</span><span style="color: #5D478B;">,</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;.yq_real &nbsp; &nbsp;<span style="color: #9F79EE;">&#40;</span>xm_real<span style="color: #9F79EE;">&#91;</span> m<span style="color: #5D478B;">+</span><span style="color: #ff0055;">1</span> <span style="color: #9F79EE;">&#93;</span><span style="color: #9F79EE;">&#91;</span><span style="color: #9F79EE;">&#40;</span>k<span style="color: #9F79EE;">&#91;</span>m<span style="color: #5D478B;">:</span><span style="color: #ff0055;">0</span><span style="color: #9F79EE;">&#93;</span> <span style="color: #5D478B;">&lt;</span> <span style="color: #9F79EE;">&#40;</span><span style="color: #ff0055;">1</span><span style="color: #5D478B;">&lt;&lt;</span>m<span style="color: #9F79EE;">&#41;</span> <span style="color: #5D478B;">?</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #9F79EE;">&#40;</span>k<span style="color: #9F79EE;">&#91;</span><span style="color: #ff0055;">3</span><span style="color: #5D478B;">:</span>m<span style="color: #9F79EE;">&#93;</span> <span style="color: #5D478B;">&lt;&lt;</span> <span style="color: #9F79EE;">&#40;</span>m<span style="color: #5D478B;">+</span><span style="color: #ff0055;">1</span><span style="color: #9F79EE;">&#41;</span><span style="color: #9F79EE;">&#41;</span> <span style="color: #5D478B;">+</span> k<span style="color: #9F79EE;">&#91;</span>m<span style="color: #5D478B;">:</span><span style="color: #ff0055;">0</span><span style="color: #9F79EE;">&#93;</span> <span style="color: #5D478B;">:</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #9F79EE;">&#40;</span>k<span style="color: #9F79EE;">&#91;</span><span style="color: #ff0055;">3</span><span style="color: #5D478B;">:</span>m<span style="color: #9F79EE;">&#93;</span> <span style="color: #5D478B;">&lt;&lt;</span> <span style="color: #9F79EE;">&#40;</span>m<span style="color: #5D478B;">+</span><span style="color: #ff0055;">1</span><span style="color: #9F79EE;">&#41;</span><span style="color: #9F79EE;">&#41;</span> <span style="color: #5D478B;">+</span> <span style="color: #9F79EE;">&#40;</span>k<span style="color: #9F79EE;">&#91;</span>m<span style="color: #5D478B;">:</span><span style="color: #ff0055;">0</span><span style="color: #9F79EE;">&#93;</span><span style="color: #5D478B;">-</span><span style="color: #9F79EE;">&#40;</span><span style="color: #ff0055;">1</span><span style="color: #5D478B;">&lt;&lt;</span>m<span style="color: #9F79EE;">&#41;</span><span style="color: #9F79EE;">&#41;</span><span style="color: #9F79EE;">&#41;</span> <span style="color: #5D478B;">+</span> <span style="color: #9F79EE;">&#40;</span><span style="color: #ff0055;">1</span><span style="color: #5D478B;">&lt;&lt;</span>m<span style="color: #9F79EE;">&#41;</span> <span style="color: #9F79EE;">&#93;</span><span style="color: #9F79EE;">&#41;</span><span style="color: #5D478B;">,</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;.yq_imag &nbsp; &nbsp;<span style="color: #9F79EE;">&#40;</span>xm_imag<span style="color: #9F79EE;">&#91;</span> m<span style="color: #5D478B;">+</span><span style="color: #ff0055;">1</span> <span style="color: #9F79EE;">&#93;</span><span style="color: #9F79EE;">&#91;</span><span style="color: #9F79EE;">&#40;</span><span style="color: #9F79EE;">&#40;</span>k<span style="color: #9F79EE;">&#91;</span>m<span style="color: #5D478B;">:</span><span style="color: #ff0055;">0</span><span style="color: #9F79EE;">&#93;</span><span style="color: #9F79EE;">&#41;</span> <span style="color: #5D478B;">&lt;</span> <span style="color: #9F79EE;">&#40;</span><span style="color: #ff0055;">1</span><span style="color: #5D478B;">&lt;&lt;</span>m<span style="color: #9F79EE;">&#41;</span> <span style="color: #5D478B;">?</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #9F79EE;">&#40;</span>k<span style="color: #9F79EE;">&#91;</span><span style="color: #ff0055;">3</span><span style="color: #5D478B;">:</span>m<span style="color: #9F79EE;">&#93;</span> <span style="color: #5D478B;">&lt;&lt;</span> <span style="color: #9F79EE;">&#40;</span>m<span style="color: #5D478B;">+</span><span style="color: #ff0055;">1</span><span style="color: #9F79EE;">&#41;</span><span style="color: #9F79EE;">&#41;</span> <span style="color: #5D478B;">+</span> k<span style="color: #9F79EE;">&#91;</span>m<span style="color: #5D478B;">:</span><span style="color: #ff0055;">0</span><span style="color: #9F79EE;">&#93;</span> <span style="color: #5D478B;">:</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #9F79EE;">&#40;</span>k<span style="color: #9F79EE;">&#91;</span><span style="color: #ff0055;">3</span><span style="color: #5D478B;">:</span>m<span style="color: #9F79EE;">&#93;</span> <span style="color: #5D478B;">&lt;&lt;</span> <span style="color: #9F79EE;">&#40;</span>m<span style="color: #5D478B;">+</span><span style="color: #ff0055;">1</span><span style="color: #9F79EE;">&#41;</span><span style="color: #9F79EE;">&#41;</span> <span style="color: #5D478B;">+</span> <span style="color: #9F79EE;">&#40;</span>k<span style="color: #9F79EE;">&#91;</span>m<span style="color: #5D478B;">:</span><span style="color: #ff0055;">0</span><span style="color: #9F79EE;">&#93;</span><span style="color: #5D478B;">-</span><span style="color: #9F79EE;">&#40;</span><span style="color: #ff0055;">1</span><span style="color: #5D478B;">&lt;&lt;</span>m<span style="color: #9F79EE;">&#41;</span><span style="color: #9F79EE;">&#41;</span><span style="color: #9F79EE;">&#41;</span> <span style="color: #5D478B;">+</span> <span style="color: #9F79EE;">&#40;</span><span style="color: #ff0055;">1</span><span style="color: #5D478B;">&lt;&lt;</span>m<span style="color: #9F79EE;">&#41;</span> <span style="color: #9F79EE;">&#93;</span><span style="color: #9F79EE;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #9F79EE;">&#41;</span><span style="color: #5D478B;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #A52A2A; font-weight: bold;">end</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #A52A2A; font-weight: bold;">end</span><br />
&nbsp; &nbsp; <span style="color: #A52A2A; font-weight: bold;">endgenerate</span><br />
<br />
&nbsp; &nbsp; <span style="color: #A52A2A; font-weight: bold;">assign</span> &nbsp; &nbsp; valid <span style="color: #5D478B;">=</span> en_connect<span style="color: #9F79EE;">&#91;</span><span style="color: #ff0055;">12</span><span style="color: #9F79EE;">&#93;</span><span style="color: #5D478B;">;</span><br />
&nbsp; &nbsp; <span style="color: #A52A2A; font-weight: bold;">assign</span> &nbsp; &nbsp; y0_real <span style="color: #5D478B;">=</span> xm_real<span style="color: #9F79EE;">&#91;</span><span style="color: #ff0055;">3</span><span style="color: #9F79EE;">&#93;</span><span style="color: #9F79EE;">&#91;</span><span style="color: #ff0055;">0</span><span style="color: #9F79EE;">&#93;</span> <span style="color: #5D478B;">;</span><br />
&nbsp; &nbsp; <span style="color: #A52A2A; font-weight: bold;">assign</span> &nbsp; &nbsp; y0_imag <span style="color: #5D478B;">=</span> xm_imag<span style="color: #9F79EE;">&#91;</span><span style="color: #ff0055;">3</span><span style="color: #9F79EE;">&#93;</span><span style="color: #9F79EE;">&#91;</span><span style="color: #ff0055;">0</span><span style="color: #9F79EE;">&#93;</span> <span style="color: #5D478B;">;</span><br />
&nbsp; &nbsp; <span style="color: #A52A2A; font-weight: bold;">assign</span> &nbsp; &nbsp; y1_real <span style="color: #5D478B;">=</span> xm_real<span style="color: #9F79EE;">&#91;</span><span style="color: #ff0055;">3</span><span style="color: #9F79EE;">&#93;</span><span style="color: #9F79EE;">&#91;</span><span style="color: #ff0055;">1</span><span style="color: #9F79EE;">&#93;</span> <span style="color: #5D478B;">;</span><br />
&nbsp; &nbsp; <span style="color: #A52A2A; font-weight: bold;">assign</span> &nbsp; &nbsp; y1_imag <span style="color: #5D478B;">=</span> xm_imag<span style="color: #9F79EE;">&#91;</span><span style="color: #ff0055;">3</span><span style="color: #9F79EE;">&#93;</span><span style="color: #9F79EE;">&#91;</span><span style="color: #ff0055;">1</span><span style="color: #9F79EE;">&#93;</span> <span style="color: #5D478B;">;</span><br />
&nbsp; &nbsp; <span style="color: #A52A2A; font-weight: bold;">assign</span> &nbsp; &nbsp; y2_real <span style="color: #5D478B;">=</span> xm_real<span style="color: #9F79EE;">&#91;</span><span style="color: #ff0055;">3</span><span style="color: #9F79EE;">&#93;</span><span style="color: #9F79EE;">&#91;</span><span style="color: #ff0055;">2</span><span style="color: #9F79EE;">&#93;</span> <span style="color: #5D478B;">;</span><br />
&nbsp; &nbsp; <span style="color: #A52A2A; font-weight: bold;">assign</span> &nbsp; &nbsp; y2_imag <span style="color: #5D478B;">=</span> xm_imag<span style="color: #9F79EE;">&#91;</span><span style="color: #ff0055;">3</span><span style="color: #9F79EE;">&#93;</span><span style="color: #9F79EE;">&#91;</span><span style="color: #ff0055;">2</span><span style="color: #9F79EE;">&#93;</span> <span style="color: #5D478B;">;</span><br />
&nbsp; &nbsp; <span style="color: #A52A2A; font-weight: bold;">assign</span> &nbsp; &nbsp; y3_real <span style="color: #5D478B;">=</span> xm_real<span style="color: #9F79EE;">&#91;</span><span style="color: #ff0055;">3</span><span style="color: #9F79EE;">&#93;</span><span style="color: #9F79EE;">&#91;</span><span style="color: #ff0055;">3</span><span style="color: #9F79EE;">&#93;</span> <span style="color: #5D478B;">;</span><br />
&nbsp; &nbsp; <span style="color: #A52A2A; font-weight: bold;">assign</span> &nbsp; &nbsp; y3_imag <span style="color: #5D478B;">=</span> xm_imag<span style="color: #9F79EE;">&#91;</span><span style="color: #ff0055;">3</span><span style="color: #9F79EE;">&#93;</span><span style="color: #9F79EE;">&#91;</span><span style="color: #ff0055;">3</span><span style="color: #9F79EE;">&#93;</span> <span style="color: #5D478B;">;</span><br />
&nbsp; &nbsp; <span style="color: #A52A2A; font-weight: bold;">assign</span> &nbsp; &nbsp; y4_real <span style="color: #5D478B;">=</span> xm_real<span style="color: #9F79EE;">&#91;</span><span style="color: #ff0055;">3</span><span style="color: #9F79EE;">&#93;</span><span style="color: #9F79EE;">&#91;</span><span style="color: #ff0055;">4</span><span style="color: #9F79EE;">&#93;</span> <span style="color: #5D478B;">;</span><br />
&nbsp; &nbsp; <span style="color: #A52A2A; font-weight: bold;">assign</span> &nbsp; &nbsp; y4_imag <span style="color: #5D478B;">=</span> xm_imag<span style="color: #9F79EE;">&#91;</span><span style="color: #ff0055;">3</span><span style="color: #9F79EE;">&#93;</span><span style="color: #9F79EE;">&#91;</span><span style="color: #ff0055;">4</span><span style="color: #9F79EE;">&#93;</span> <span style="color: #5D478B;">;</span><br />
&nbsp; &nbsp; <span style="color: #A52A2A; font-weight: bold;">assign</span> &nbsp; &nbsp; y5_real <span style="color: #5D478B;">=</span> xm_real<span style="color: #9F79EE;">&#91;</span><span style="color: #ff0055;">3</span><span style="color: #9F79EE;">&#93;</span><span style="color: #9F79EE;">&#91;</span><span style="color: #ff0055;">5</span><span style="color: #9F79EE;">&#93;</span> <span style="color: #5D478B;">;</span><br />
&nbsp; &nbsp; <span style="color: #A52A2A; font-weight: bold;">assign</span> &nbsp; &nbsp; y5_imag <span style="color: #5D478B;">=</span> xm_imag<span style="color: #9F79EE;">&#91;</span><span style="color: #ff0055;">3</span><span style="color: #9F79EE;">&#93;</span><span style="color: #9F79EE;">&#91;</span><span style="color: #ff0055;">5</span><span style="color: #9F79EE;">&#93;</span> <span style="color: #5D478B;">;</span><br />
&nbsp; &nbsp; <span style="color: #A52A2A; font-weight: bold;">assign</span> &nbsp; &nbsp; y6_real <span style="color: #5D478B;">=</span> xm_real<span style="color: #9F79EE;">&#91;</span><span style="color: #ff0055;">3</span><span style="color: #9F79EE;">&#93;</span><span style="color: #9F79EE;">&#91;</span><span style="color: #ff0055;">6</span><span style="color: #9F79EE;">&#93;</span> <span style="color: #5D478B;">;</span><br />
&nbsp; &nbsp; <span style="color: #A52A2A; font-weight: bold;">assign</span> &nbsp; &nbsp; y6_imag <span style="color: #5D478B;">=</span> xm_imag<span style="color: #9F79EE;">&#91;</span><span style="color: #ff0055;">3</span><span style="color: #9F79EE;">&#93;</span><span style="color: #9F79EE;">&#91;</span><span style="color: #ff0055;">6</span><span style="color: #9F79EE;">&#93;</span> <span style="color: #5D478B;">;</span><br />
&nbsp; &nbsp; <span style="color: #A52A2A; font-weight: bold;">assign</span> &nbsp; &nbsp; y7_real <span style="color: #5D478B;">=</span> xm_real<span style="color: #9F79EE;">&#91;</span><span style="color: #ff0055;">3</span><span style="color: #9F79EE;">&#93;</span><span style="color: #9F79EE;">&#91;</span><span style="color: #ff0055;">7</span><span style="color: #9F79EE;">&#93;</span> <span style="color: #5D478B;">;</span><br />
&nbsp; &nbsp; <span style="color: #A52A2A; font-weight: bold;">assign</span> &nbsp; &nbsp; y7_imag <span style="color: #5D478B;">=</span> xm_imag<span style="color: #9F79EE;">&#91;</span><span style="color: #ff0055;">3</span><span style="color: #9F79EE;">&#93;</span><span style="color: #9F79EE;">&#91;</span><span style="color: #ff0055;">7</span><span style="color: #9F79EE;">&#93;</span> <span style="color: #5D478B;">;</span><br />
<br />
<span style="color: #A52A2A; font-weight: bold;">endmodule</span><br />
</div></div>
<p><strong>testbench</strong></p><p>
testbench 编写如下，主要用于 16 路实、复数据的连续输入。因为每次 FFT 只有 8 点数据，所以送入的数据比较随意，并不是正弦波等规则的数据。</p>
<div class="example"><h2 class="example">实例</h2> <div class="example_code">
<span style="color: #008800;">`timescale</span> <span style="color: #ff0055;">1ns</span><span style="color: #5D478B;">/</span><span style="color: #ff0055;">100ps</span><br />
<span style="color: #A52A2A; font-weight: bold;">module</span> test <span style="color: #5D478B;">;</span><br />
&nbsp; &nbsp; <span style="color: #A52A2A; font-weight: bold;">reg</span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;clk<span style="color: #5D478B;">;</span><br />
&nbsp; &nbsp; <span style="color: #A52A2A; font-weight: bold;">reg</span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;rstn<span style="color: #5D478B;">;</span><br />
&nbsp; &nbsp; <span style="color: #A52A2A; font-weight: bold;">reg</span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;en <span style="color: #5D478B;">;</span><br />
<br />
&nbsp; &nbsp; <span style="color: #A52A2A; font-weight: bold;">reg</span> <span style="color: #A52A2A; font-weight: bold;">signed</span> &nbsp; <span style="color: #9F79EE;">&#91;</span><span style="color: #ff0055;">23</span><span style="color: #5D478B;">:</span><span style="color: #ff0055;">0</span><span style="color: #9F79EE;">&#93;</span> &nbsp; x0_real<span style="color: #5D478B;">;</span><br />
&nbsp; &nbsp; <span style="color: #A52A2A; font-weight: bold;">reg</span> <span style="color: #A52A2A; font-weight: bold;">signed</span> &nbsp; <span style="color: #9F79EE;">&#91;</span><span style="color: #ff0055;">23</span><span style="color: #5D478B;">:</span><span style="color: #ff0055;">0</span><span style="color: #9F79EE;">&#93;</span> &nbsp; x0_imag<span style="color: #5D478B;">;</span><br />
&nbsp; &nbsp; <span style="color: #A52A2A; font-weight: bold;">reg</span> <span style="color: #A52A2A; font-weight: bold;">signed</span> &nbsp; <span style="color: #9F79EE;">&#91;</span><span style="color: #ff0055;">23</span><span style="color: #5D478B;">:</span><span style="color: #ff0055;">0</span><span style="color: #9F79EE;">&#93;</span> &nbsp; x1_real<span style="color: #5D478B;">;</span><br />
&nbsp; &nbsp; <span style="color: #A52A2A; font-weight: bold;">reg</span> <span style="color: #A52A2A; font-weight: bold;">signed</span> &nbsp; <span style="color: #9F79EE;">&#91;</span><span style="color: #ff0055;">23</span><span style="color: #5D478B;">:</span><span style="color: #ff0055;">0</span><span style="color: #9F79EE;">&#93;</span> &nbsp; x1_imag<span style="color: #5D478B;">;</span><br />
&nbsp; &nbsp; <span style="color: #A52A2A; font-weight: bold;">reg</span> <span style="color: #A52A2A; font-weight: bold;">signed</span> &nbsp; <span style="color: #9F79EE;">&#91;</span><span style="color: #ff0055;">23</span><span style="color: #5D478B;">:</span><span style="color: #ff0055;">0</span><span style="color: #9F79EE;">&#93;</span> &nbsp; x2_real<span style="color: #5D478B;">;</span><br />
&nbsp; &nbsp; <span style="color: #A52A2A; font-weight: bold;">reg</span> <span style="color: #A52A2A; font-weight: bold;">signed</span> &nbsp; <span style="color: #9F79EE;">&#91;</span><span style="color: #ff0055;">23</span><span style="color: #5D478B;">:</span><span style="color: #ff0055;">0</span><span style="color: #9F79EE;">&#93;</span> &nbsp; x2_imag<span style="color: #5D478B;">;</span><br />
&nbsp; &nbsp; <span style="color: #A52A2A; font-weight: bold;">reg</span> <span style="color: #A52A2A; font-weight: bold;">signed</span> &nbsp; <span style="color: #9F79EE;">&#91;</span><span style="color: #ff0055;">23</span><span style="color: #5D478B;">:</span><span style="color: #ff0055;">0</span><span style="color: #9F79EE;">&#93;</span> &nbsp; x3_real<span style="color: #5D478B;">;</span><br />
&nbsp; &nbsp; <span style="color: #A52A2A; font-weight: bold;">reg</span> <span style="color: #A52A2A; font-weight: bold;">signed</span> &nbsp; <span style="color: #9F79EE;">&#91;</span><span style="color: #ff0055;">23</span><span style="color: #5D478B;">:</span><span style="color: #ff0055;">0</span><span style="color: #9F79EE;">&#93;</span> &nbsp; x3_imag<span style="color: #5D478B;">;</span><br />
&nbsp; &nbsp; <span style="color: #A52A2A; font-weight: bold;">reg</span> <span style="color: #A52A2A; font-weight: bold;">signed</span> &nbsp; <span style="color: #9F79EE;">&#91;</span><span style="color: #ff0055;">23</span><span style="color: #5D478B;">:</span><span style="color: #ff0055;">0</span><span style="color: #9F79EE;">&#93;</span> &nbsp; x4_real<span style="color: #5D478B;">;</span><br />
&nbsp; &nbsp; <span style="color: #A52A2A; font-weight: bold;">reg</span> <span style="color: #A52A2A; font-weight: bold;">signed</span> &nbsp; <span style="color: #9F79EE;">&#91;</span><span style="color: #ff0055;">23</span><span style="color: #5D478B;">:</span><span style="color: #ff0055;">0</span><span style="color: #9F79EE;">&#93;</span> &nbsp; x4_imag<span style="color: #5D478B;">;</span><br />
&nbsp; &nbsp; <span style="color: #A52A2A; font-weight: bold;">reg</span> <span style="color: #A52A2A; font-weight: bold;">signed</span> &nbsp; <span style="color: #9F79EE;">&#91;</span><span style="color: #ff0055;">23</span><span style="color: #5D478B;">:</span><span style="color: #ff0055;">0</span><span style="color: #9F79EE;">&#93;</span> &nbsp; x5_real<span style="color: #5D478B;">;</span><br />
&nbsp; &nbsp; <span style="color: #A52A2A; font-weight: bold;">reg</span> <span style="color: #A52A2A; font-weight: bold;">signed</span> &nbsp; <span style="color: #9F79EE;">&#91;</span><span style="color: #ff0055;">23</span><span style="color: #5D478B;">:</span><span style="color: #ff0055;">0</span><span style="color: #9F79EE;">&#93;</span> &nbsp; x5_imag<span style="color: #5D478B;">;</span><br />
&nbsp; &nbsp; <span style="color: #A52A2A; font-weight: bold;">reg</span> <span style="color: #A52A2A; font-weight: bold;">signed</span> &nbsp; <span style="color: #9F79EE;">&#91;</span><span style="color: #ff0055;">23</span><span style="color: #5D478B;">:</span><span style="color: #ff0055;">0</span><span style="color: #9F79EE;">&#93;</span> &nbsp; x6_real<span style="color: #5D478B;">;</span><br />
&nbsp; &nbsp; <span style="color: #A52A2A; font-weight: bold;">reg</span> <span style="color: #A52A2A; font-weight: bold;">signed</span> &nbsp; <span style="color: #9F79EE;">&#91;</span><span style="color: #ff0055;">23</span><span style="color: #5D478B;">:</span><span style="color: #ff0055;">0</span><span style="color: #9F79EE;">&#93;</span> &nbsp; x6_imag<span style="color: #5D478B;">;</span><br />
&nbsp; &nbsp; <span style="color: #A52A2A; font-weight: bold;">reg</span> <span style="color: #A52A2A; font-weight: bold;">signed</span> &nbsp; <span style="color: #9F79EE;">&#91;</span><span style="color: #ff0055;">23</span><span style="color: #5D478B;">:</span><span style="color: #ff0055;">0</span><span style="color: #9F79EE;">&#93;</span> &nbsp; x7_real<span style="color: #5D478B;">;</span><br />
&nbsp; &nbsp; <span style="color: #A52A2A; font-weight: bold;">reg</span> <span style="color: #A52A2A; font-weight: bold;">signed</span> &nbsp; <span style="color: #9F79EE;">&#91;</span><span style="color: #ff0055;">23</span><span style="color: #5D478B;">:</span><span style="color: #ff0055;">0</span><span style="color: #9F79EE;">&#93;</span> &nbsp; x7_imag<span style="color: #5D478B;">;</span><br />
<br />
&nbsp; &nbsp; <span style="color: #A52A2A; font-weight: bold;">wire</span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;valid<span style="color: #5D478B;">;</span><br />
&nbsp; &nbsp; <span style="color: #A52A2A; font-weight: bold;">wire</span> <span style="color: #A52A2A; font-weight: bold;">signed</span> &nbsp;<span style="color: #9F79EE;">&#91;</span><span style="color: #ff0055;">23</span><span style="color: #5D478B;">:</span><span style="color: #ff0055;">0</span><span style="color: #9F79EE;">&#93;</span> &nbsp; y0_real<span style="color: #5D478B;">;</span><br />
&nbsp; &nbsp; <span style="color: #A52A2A; font-weight: bold;">wire</span> <span style="color: #A52A2A; font-weight: bold;">signed</span> &nbsp;<span style="color: #9F79EE;">&#91;</span><span style="color: #ff0055;">23</span><span style="color: #5D478B;">:</span><span style="color: #ff0055;">0</span><span style="color: #9F79EE;">&#93;</span> &nbsp; y0_imag<span style="color: #5D478B;">;</span><br />
&nbsp; &nbsp; <span style="color: #A52A2A; font-weight: bold;">wire</span> <span style="color: #A52A2A; font-weight: bold;">signed</span> &nbsp;<span style="color: #9F79EE;">&#91;</span><span style="color: #ff0055;">23</span><span style="color: #5D478B;">:</span><span style="color: #ff0055;">0</span><span style="color: #9F79EE;">&#93;</span> &nbsp; y1_real<span style="color: #5D478B;">;</span><br />
&nbsp; &nbsp; <span style="color: #A52A2A; font-weight: bold;">wire</span> <span style="color: #A52A2A; font-weight: bold;">signed</span> &nbsp;<span style="color: #9F79EE;">&#91;</span><span style="color: #ff0055;">23</span><span style="color: #5D478B;">:</span><span style="color: #ff0055;">0</span><span style="color: #9F79EE;">&#93;</span> &nbsp; y1_imag<span style="color: #5D478B;">;</span><br />
&nbsp; &nbsp; <span style="color: #A52A2A; font-weight: bold;">wire</span> <span style="color: #A52A2A; font-weight: bold;">signed</span> &nbsp;<span style="color: #9F79EE;">&#91;</span><span style="color: #ff0055;">23</span><span style="color: #5D478B;">:</span><span style="color: #ff0055;">0</span><span style="color: #9F79EE;">&#93;</span> &nbsp; y2_real<span style="color: #5D478B;">;</span><br />
&nbsp; &nbsp; <span style="color: #A52A2A; font-weight: bold;">wire</span> <span style="color: #A52A2A; font-weight: bold;">signed</span> &nbsp;<span style="color: #9F79EE;">&#91;</span><span style="color: #ff0055;">23</span><span style="color: #5D478B;">:</span><span style="color: #ff0055;">0</span><span style="color: #9F79EE;">&#93;</span> &nbsp; y2_imag<span style="color: #5D478B;">;</span><br />
&nbsp; &nbsp; <span style="color: #A52A2A; font-weight: bold;">wire</span> <span style="color: #A52A2A; font-weight: bold;">signed</span> &nbsp;<span style="color: #9F79EE;">&#91;</span><span style="color: #ff0055;">23</span><span style="color: #5D478B;">:</span><span style="color: #ff0055;">0</span><span style="color: #9F79EE;">&#93;</span> &nbsp; y3_real<span style="color: #5D478B;">;</span><br />
&nbsp; &nbsp; <span style="color: #A52A2A; font-weight: bold;">wire</span> <span style="color: #A52A2A; font-weight: bold;">signed</span> &nbsp;<span style="color: #9F79EE;">&#91;</span><span style="color: #ff0055;">23</span><span style="color: #5D478B;">:</span><span style="color: #ff0055;">0</span><span style="color: #9F79EE;">&#93;</span> &nbsp; y3_imag<span style="color: #5D478B;">;</span><br />
&nbsp; &nbsp; <span style="color: #A52A2A; font-weight: bold;">wire</span> <span style="color: #A52A2A; font-weight: bold;">signed</span> &nbsp;<span style="color: #9F79EE;">&#91;</span><span style="color: #ff0055;">23</span><span style="color: #5D478B;">:</span><span style="color: #ff0055;">0</span><span style="color: #9F79EE;">&#93;</span> &nbsp; y4_real<span style="color: #5D478B;">;</span><br />
&nbsp; &nbsp; <span style="color: #A52A2A; font-weight: bold;">wire</span> <span style="color: #A52A2A; font-weight: bold;">signed</span> &nbsp;<span style="color: #9F79EE;">&#91;</span><span style="color: #ff0055;">23</span><span style="color: #5D478B;">:</span><span style="color: #ff0055;">0</span><span style="color: #9F79EE;">&#93;</span> &nbsp; y4_imag<span style="color: #5D478B;">;</span><br />
&nbsp; &nbsp; <span style="color: #A52A2A; font-weight: bold;">wire</span> <span style="color: #A52A2A; font-weight: bold;">signed</span> &nbsp;<span style="color: #9F79EE;">&#91;</span><span style="color: #ff0055;">23</span><span style="color: #5D478B;">:</span><span style="color: #ff0055;">0</span><span style="color: #9F79EE;">&#93;</span> &nbsp; y5_real<span style="color: #5D478B;">;</span><br />
&nbsp; &nbsp; <span style="color: #A52A2A; font-weight: bold;">wire</span> <span style="color: #A52A2A; font-weight: bold;">signed</span> &nbsp;<span style="color: #9F79EE;">&#91;</span><span style="color: #ff0055;">23</span><span style="color: #5D478B;">:</span><span style="color: #ff0055;">0</span><span style="color: #9F79EE;">&#93;</span> &nbsp; y5_imag<span style="color: #5D478B;">;</span><br />
&nbsp; &nbsp; <span style="color: #A52A2A; font-weight: bold;">wire</span> <span style="color: #A52A2A; font-weight: bold;">signed</span> &nbsp;<span style="color: #9F79EE;">&#91;</span><span style="color: #ff0055;">23</span><span style="color: #5D478B;">:</span><span style="color: #ff0055;">0</span><span style="color: #9F79EE;">&#93;</span> &nbsp; y6_real<span style="color: #5D478B;">;</span><br />
&nbsp; &nbsp; <span style="color: #A52A2A; font-weight: bold;">wire</span> <span style="color: #A52A2A; font-weight: bold;">signed</span> &nbsp;<span style="color: #9F79EE;">&#91;</span><span style="color: #ff0055;">23</span><span style="color: #5D478B;">:</span><span style="color: #ff0055;">0</span><span style="color: #9F79EE;">&#93;</span> &nbsp; y6_imag<span style="color: #5D478B;">;</span><br />
&nbsp; &nbsp; <span style="color: #A52A2A; font-weight: bold;">wire</span> <span style="color: #A52A2A; font-weight: bold;">signed</span> &nbsp;<span style="color: #9F79EE;">&#91;</span><span style="color: #ff0055;">23</span><span style="color: #5D478B;">:</span><span style="color: #ff0055;">0</span><span style="color: #9F79EE;">&#93;</span> &nbsp; y7_real<span style="color: #5D478B;">;</span><br />
&nbsp; &nbsp; <span style="color: #A52A2A; font-weight: bold;">wire</span> <span style="color: #A52A2A; font-weight: bold;">signed</span> &nbsp;<span style="color: #9F79EE;">&#91;</span><span style="color: #ff0055;">23</span><span style="color: #5D478B;">:</span><span style="color: #ff0055;">0</span><span style="color: #9F79EE;">&#93;</span> &nbsp; y7_imag<span style="color: #5D478B;">;</span><br />
<br />
&nbsp; &nbsp; <span style="color: #A52A2A; font-weight: bold;">initial</span> <span style="color: #A52A2A; font-weight: bold;">begin</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; clk <span style="color: #5D478B;">=</span> <span style="color: #ff0055;">0</span><span style="color: #5D478B;">;</span> <span style="color: #00008B; font-style: italic;">//50MHz</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; rstn <span style="color: #5D478B;">=</span> <span style="color: #ff0055;">0</span> <span style="color: #5D478B;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #5D478B;">#</span><span style="color: #ff0055;">10</span> rstn <span style="color: #5D478B;">=</span> <span style="color: #ff0055;">1</span><span style="color: #5D478B;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #A52A2A; font-weight: bold;">forever</span> <span style="color: #A52A2A; font-weight: bold;">begin</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #5D478B;">#</span><span style="color: #ff0055;">10</span> clk <span style="color: #5D478B;">=</span> <span style="color: #5D478B;">~</span>clk<span style="color: #5D478B;">;</span> <span style="color: #00008B; font-style: italic;">//50MHz</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #A52A2A; font-weight: bold;">end</span><br />
&nbsp; &nbsp; <span style="color: #A52A2A; font-weight: bold;">end</span><br />
<br />
&nbsp; &nbsp; fft8 u_fft <span style="color: #9F79EE;">&#40;</span><br />
&nbsp; &nbsp; &nbsp; .clk &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #9F79EE;">&#40;</span>clk &nbsp; &nbsp;<span style="color: #9F79EE;">&#41;</span><span style="color: #5D478B;">,</span><br />
&nbsp; &nbsp; &nbsp; .rstn &nbsp; &nbsp; &nbsp; <span style="color: #9F79EE;">&#40;</span>rstn &nbsp; &nbsp;<span style="color: #9F79EE;">&#41;</span><span style="color: #5D478B;">,</span><br />
&nbsp; &nbsp; &nbsp; .en &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #9F79EE;">&#40;</span>en &nbsp; &nbsp; <span style="color: #9F79EE;">&#41;</span><span style="color: #5D478B;">,</span><br />
&nbsp; &nbsp; &nbsp; .x0_real &nbsp; &nbsp;<span style="color: #9F79EE;">&#40;</span>x0_real<span style="color: #9F79EE;">&#41;</span><span style="color: #5D478B;">,</span><br />
&nbsp; &nbsp; &nbsp; .x0_imag &nbsp; &nbsp;<span style="color: #9F79EE;">&#40;</span>x0_imag<span style="color: #9F79EE;">&#41;</span><span style="color: #5D478B;">,</span><br />
&nbsp; &nbsp; &nbsp; .x1_real &nbsp; &nbsp;<span style="color: #9F79EE;">&#40;</span>x1_real<span style="color: #9F79EE;">&#41;</span><span style="color: #5D478B;">,</span><br />
&nbsp; &nbsp; &nbsp; .x1_imag &nbsp; &nbsp;<span style="color: #9F79EE;">&#40;</span>x1_imag<span style="color: #9F79EE;">&#41;</span><span style="color: #5D478B;">,</span><br />
&nbsp; &nbsp; &nbsp; .x2_real &nbsp; &nbsp;<span style="color: #9F79EE;">&#40;</span>x2_real<span style="color: #9F79EE;">&#41;</span><span style="color: #5D478B;">,</span><br />
&nbsp; &nbsp; &nbsp; .x2_imag &nbsp; &nbsp;<span style="color: #9F79EE;">&#40;</span>x2_imag<span style="color: #9F79EE;">&#41;</span><span style="color: #5D478B;">,</span><br />
&nbsp; &nbsp; &nbsp; .x3_real &nbsp; &nbsp;<span style="color: #9F79EE;">&#40;</span>x3_real<span style="color: #9F79EE;">&#41;</span><span style="color: #5D478B;">,</span><br />
&nbsp; &nbsp; &nbsp; .x3_imag &nbsp; &nbsp;<span style="color: #9F79EE;">&#40;</span>x3_imag<span style="color: #9F79EE;">&#41;</span><span style="color: #5D478B;">,</span><br />
&nbsp; &nbsp; &nbsp; .x4_real &nbsp; &nbsp;<span style="color: #9F79EE;">&#40;</span>x4_real<span style="color: #9F79EE;">&#41;</span><span style="color: #5D478B;">,</span><br />
&nbsp; &nbsp; &nbsp; .x4_imag &nbsp; &nbsp;<span style="color: #9F79EE;">&#40;</span>x4_imag<span style="color: #9F79EE;">&#41;</span><span style="color: #5D478B;">,</span><br />
&nbsp; &nbsp; &nbsp; .x5_real &nbsp; &nbsp;<span style="color: #9F79EE;">&#40;</span>x5_real<span style="color: #9F79EE;">&#41;</span><span style="color: #5D478B;">,</span><br />
&nbsp; &nbsp; &nbsp; .x5_imag &nbsp; &nbsp;<span style="color: #9F79EE;">&#40;</span>x5_imag<span style="color: #9F79EE;">&#41;</span><span style="color: #5D478B;">,</span><br />
&nbsp; &nbsp; &nbsp; .x6_real &nbsp; &nbsp;<span style="color: #9F79EE;">&#40;</span>x6_real<span style="color: #9F79EE;">&#41;</span><span style="color: #5D478B;">,</span><br />
&nbsp; &nbsp; &nbsp; .x6_imag &nbsp; &nbsp;<span style="color: #9F79EE;">&#40;</span>x6_imag<span style="color: #9F79EE;">&#41;</span><span style="color: #5D478B;">,</span><br />
&nbsp; &nbsp; &nbsp; .x7_real &nbsp; &nbsp;<span style="color: #9F79EE;">&#40;</span>x7_real<span style="color: #9F79EE;">&#41;</span><span style="color: #5D478B;">,</span><br />
&nbsp; &nbsp; &nbsp; .x7_imag &nbsp; &nbsp;<span style="color: #9F79EE;">&#40;</span>x7_imag<span style="color: #9F79EE;">&#41;</span><span style="color: #5D478B;">,</span><br />
<br />
&nbsp; &nbsp; &nbsp; .valid &nbsp; &nbsp; &nbsp;<span style="color: #9F79EE;">&#40;</span>valid<span style="color: #9F79EE;">&#41;</span><span style="color: #5D478B;">,</span><br />
&nbsp; &nbsp; &nbsp; .y0_real &nbsp; &nbsp;<span style="color: #9F79EE;">&#40;</span>y0_real<span style="color: #9F79EE;">&#41;</span><span style="color: #5D478B;">,</span><br />
&nbsp; &nbsp; &nbsp; .y0_imag &nbsp; &nbsp;<span style="color: #9F79EE;">&#40;</span>y0_imag<span style="color: #9F79EE;">&#41;</span><span style="color: #5D478B;">,</span><br />
&nbsp; &nbsp; &nbsp; .y1_real &nbsp; &nbsp;<span style="color: #9F79EE;">&#40;</span>y1_real<span style="color: #9F79EE;">&#41;</span><span style="color: #5D478B;">,</span><br />
&nbsp; &nbsp; &nbsp; .y1_imag &nbsp; &nbsp;<span style="color: #9F79EE;">&#40;</span>y1_imag<span style="color: #9F79EE;">&#41;</span><span style="color: #5D478B;">,</span><br />
&nbsp; &nbsp; &nbsp; .y2_real &nbsp; &nbsp;<span style="color: #9F79EE;">&#40;</span>y2_real<span style="color: #9F79EE;">&#41;</span><span style="color: #5D478B;">,</span><br />
&nbsp; &nbsp; &nbsp; .y2_imag &nbsp; &nbsp;<span style="color: #9F79EE;">&#40;</span>y2_imag<span style="color: #9F79EE;">&#41;</span><span style="color: #5D478B;">,</span><br />
&nbsp; &nbsp; &nbsp; .y3_real &nbsp; &nbsp;<span style="color: #9F79EE;">&#40;</span>y3_real<span style="color: #9F79EE;">&#41;</span><span style="color: #5D478B;">,</span><br />
&nbsp; &nbsp; &nbsp; .y3_imag &nbsp; &nbsp;<span style="color: #9F79EE;">&#40;</span>y3_imag<span style="color: #9F79EE;">&#41;</span><span style="color: #5D478B;">,</span><br />
&nbsp; &nbsp; &nbsp; .y4_real &nbsp; &nbsp;<span style="color: #9F79EE;">&#40;</span>y4_real<span style="color: #9F79EE;">&#41;</span><span style="color: #5D478B;">,</span><br />
&nbsp; &nbsp; &nbsp; .y4_imag &nbsp; &nbsp;<span style="color: #9F79EE;">&#40;</span>y4_imag<span style="color: #9F79EE;">&#41;</span><span style="color: #5D478B;">,</span><br />
&nbsp; &nbsp; &nbsp; .y5_real &nbsp; &nbsp;<span style="color: #9F79EE;">&#40;</span>y5_real<span style="color: #9F79EE;">&#41;</span><span style="color: #5D478B;">,</span><br />
&nbsp; &nbsp; &nbsp; .y5_imag &nbsp; &nbsp;<span style="color: #9F79EE;">&#40;</span>y5_imag<span style="color: #9F79EE;">&#41;</span><span style="color: #5D478B;">,</span><br />
&nbsp; &nbsp; &nbsp; .y6_real &nbsp; &nbsp;<span style="color: #9F79EE;">&#40;</span>y6_real<span style="color: #9F79EE;">&#41;</span><span style="color: #5D478B;">,</span><br />
&nbsp; &nbsp; &nbsp; .y6_imag &nbsp; &nbsp;<span style="color: #9F79EE;">&#40;</span>y6_imag<span style="color: #9F79EE;">&#41;</span><span style="color: #5D478B;">,</span><br />
&nbsp; &nbsp; &nbsp; .y7_real &nbsp; &nbsp;<span style="color: #9F79EE;">&#40;</span>y7_real<span style="color: #9F79EE;">&#41;</span><span style="color: #5D478B;">,</span><br />
&nbsp; &nbsp; &nbsp; .y7_imag &nbsp; &nbsp;<span style="color: #9F79EE;">&#40;</span>y7_imag<span style="color: #9F79EE;">&#41;</span><span style="color: #9F79EE;">&#41;</span><span style="color: #5D478B;">;</span><br />
<br />
&nbsp; &nbsp; <span style="color: #00008B; font-style: italic;">//data input</span><br />
&nbsp; &nbsp; <span style="color: #A52A2A; font-weight: bold;">initial</span> &nbsp; &nbsp; &nbsp;<span style="color: #A52A2A; font-weight: bold;">begin</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; en <span style="color: #5D478B;">=</span> <span style="color: #ff0055;">0</span> <span style="color: #5D478B;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; x0_real <span style="color: #5D478B;">=</span> <span style="color: #ff0055;">2</span><span style="color: #ff0055;">4'd10</span><span style="color: #5D478B;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; x1_real <span style="color: #5D478B;">=</span> <span style="color: #ff0055;">2</span><span style="color: #ff0055;">4'd20</span><span style="color: #5D478B;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; x2_real <span style="color: #5D478B;">=</span> <span style="color: #ff0055;">2</span><span style="color: #ff0055;">4'd30</span><span style="color: #5D478B;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; x3_real <span style="color: #5D478B;">=</span> <span style="color: #ff0055;">2</span><span style="color: #ff0055;">4'd40</span><span style="color: #5D478B;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; x4_real <span style="color: #5D478B;">=</span> <span style="color: #ff0055;">2</span><span style="color: #ff0055;">4'd10</span><span style="color: #5D478B;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; x5_real <span style="color: #5D478B;">=</span> <span style="color: #ff0055;">2</span><span style="color: #ff0055;">4'd20</span><span style="color: #5D478B;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; x6_real <span style="color: #5D478B;">=</span> <span style="color: #ff0055;">2</span><span style="color: #ff0055;">4'd30</span><span style="color: #5D478B;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; x7_real <span style="color: #5D478B;">=</span> <span style="color: #ff0055;">2</span><span style="color: #ff0055;">4'd40</span><span style="color: #5D478B;">;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; x0_imag <span style="color: #5D478B;">=</span> <span style="color: #ff0055;">2</span><span style="color: #ff0055;">4'd0</span><span style="color: #5D478B;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; x1_imag <span style="color: #5D478B;">=</span> <span style="color: #ff0055;">2</span><span style="color: #ff0055;">4'd0</span><span style="color: #5D478B;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; x2_imag <span style="color: #5D478B;">=</span> <span style="color: #ff0055;">2</span><span style="color: #ff0055;">4'd0</span><span style="color: #5D478B;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; x3_imag <span style="color: #5D478B;">=</span> <span style="color: #ff0055;">2</span><span style="color: #ff0055;">4'd0</span><span style="color: #5D478B;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; x4_imag <span style="color: #5D478B;">=</span> <span style="color: #ff0055;">2</span><span style="color: #ff0055;">4'd0</span><span style="color: #5D478B;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; x5_imag <span style="color: #5D478B;">=</span> <span style="color: #ff0055;">2</span><span style="color: #ff0055;">4'd0</span><span style="color: #5D478B;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; x6_imag <span style="color: #5D478B;">=</span> <span style="color: #ff0055;">2</span><span style="color: #ff0055;">4'd0</span><span style="color: #5D478B;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; x7_imag <span style="color: #5D478B;">=</span> <span style="color: #ff0055;">2</span><span style="color: #ff0055;">4'd0</span><span style="color: #5D478B;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #5D478B;">@</span><span style="color: #9F79EE;">&#40;</span><span style="color: #A52A2A; font-weight: bold;">negedge</span> clk<span style="color: #9F79EE;">&#41;</span> <span style="color: #5D478B;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; en <span style="color: #5D478B;">=</span> <span style="color: #ff0055;">1</span> <span style="color: #5D478B;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #A52A2A; font-weight: bold;">forever</span> <span style="color: #A52A2A; font-weight: bold;">begin</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #5D478B;">@</span><span style="color: #9F79EE;">&#40;</span><span style="color: #A52A2A; font-weight: bold;">negedge</span> clk<span style="color: #9F79EE;">&#41;</span> <span style="color: #5D478B;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; x0_real <span style="color: #5D478B;">=</span> <span style="color: #9F79EE;">&#40;</span>x0_real <span style="color: #5D478B;">&gt;</span> <span style="color: #ff0055;">2</span><span style="color: #ff0055;">2'h3F_ffff</span><span style="color: #9F79EE;">&#41;</span> <span style="color: #5D478B;">?</span> 'b0 <span style="color: #5D478B;">:</span> x0_real <span style="color: #5D478B;">+</span> <span style="color: #ff0055;">1</span> <span style="color: #5D478B;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; x1_real <span style="color: #5D478B;">=</span> <span style="color: #9F79EE;">&#40;</span>x1_real <span style="color: #5D478B;">&gt;</span> <span style="color: #ff0055;">2</span><span style="color: #ff0055;">2'h3F_ffff</span><span style="color: #9F79EE;">&#41;</span> <span style="color: #5D478B;">?</span> 'b0 <span style="color: #5D478B;">:</span> x1_real <span style="color: #5D478B;">+</span> <span style="color: #ff0055;">1</span> <span style="color: #5D478B;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; x2_real <span style="color: #5D478B;">=</span> <span style="color: #9F79EE;">&#40;</span>x2_real <span style="color: #5D478B;">&gt;</span> <span style="color: #ff0055;">2</span><span style="color: #ff0055;">2'h3F_ffff</span><span style="color: #9F79EE;">&#41;</span> <span style="color: #5D478B;">?</span> 'b0 <span style="color: #5D478B;">:</span> x2_real <span style="color: #5D478B;">+</span> <span style="color: #ff0055;">31</span> <span style="color: #5D478B;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; x3_real <span style="color: #5D478B;">=</span> <span style="color: #9F79EE;">&#40;</span>x3_real <span style="color: #5D478B;">&gt;</span> <span style="color: #ff0055;">2</span><span style="color: #ff0055;">2'h3F_ffff</span><span style="color: #9F79EE;">&#41;</span> <span style="color: #5D478B;">?</span> 'b0 <span style="color: #5D478B;">:</span> x3_real <span style="color: #5D478B;">+</span> <span style="color: #ff0055;">1</span> <span style="color: #5D478B;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; x4_real <span style="color: #5D478B;">=</span> <span style="color: #9F79EE;">&#40;</span>x4_real <span style="color: #5D478B;">&gt;</span> <span style="color: #ff0055;">2</span><span style="color: #ff0055;">2'h3F_ffff</span><span style="color: #9F79EE;">&#41;</span> <span style="color: #5D478B;">?</span> 'b0 <span style="color: #5D478B;">:</span> x4_real <span style="color: #5D478B;">+</span> <span style="color: #ff0055;">23</span> <span style="color: #5D478B;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; x5_real <span style="color: #5D478B;">=</span> <span style="color: #9F79EE;">&#40;</span>x5_real <span style="color: #5D478B;">&gt;</span> <span style="color: #ff0055;">2</span><span style="color: #ff0055;">2'h3F_ffff</span><span style="color: #9F79EE;">&#41;</span> <span style="color: #5D478B;">?</span> 'b0 <span style="color: #5D478B;">:</span> x5_real <span style="color: #5D478B;">+</span> <span style="color: #ff0055;">1</span> <span style="color: #5D478B;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; x6_real <span style="color: #5D478B;">=</span> <span style="color: #9F79EE;">&#40;</span>x6_real <span style="color: #5D478B;">&gt;</span> <span style="color: #ff0055;">2</span><span style="color: #ff0055;">2'h3F_ffff</span><span style="color: #9F79EE;">&#41;</span> <span style="color: #5D478B;">?</span> 'b0 <span style="color: #5D478B;">:</span> x6_real <span style="color: #5D478B;">+</span> <span style="color: #ff0055;">6</span> <span style="color: #5D478B;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; x7_real <span style="color: #5D478B;">=</span> <span style="color: #9F79EE;">&#40;</span>x7_real <span style="color: #5D478B;">&gt;</span> <span style="color: #ff0055;">2</span><span style="color: #ff0055;">2'h3F_ffff</span><span style="color: #9F79EE;">&#41;</span> <span style="color: #5D478B;">?</span> 'b0 <span style="color: #5D478B;">:</span> x7_real <span style="color: #5D478B;">+</span> <span style="color: #ff0055;">1</span> <span style="color: #5D478B;">;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; x0_imag <span style="color: #5D478B;">=</span> <span style="color: #9F79EE;">&#40;</span>x0_imag <span style="color: #5D478B;">&gt;</span> <span style="color: #ff0055;">2</span><span style="color: #ff0055;">2'h3F_ffff</span><span style="color: #9F79EE;">&#41;</span> <span style="color: #5D478B;">?</span> 'b0 <span style="color: #5D478B;">:</span> x0_imag <span style="color: #5D478B;">+</span> <span style="color: #ff0055;">2</span> <span style="color: #5D478B;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; x1_imag <span style="color: #5D478B;">=</span> <span style="color: #9F79EE;">&#40;</span>x1_imag <span style="color: #5D478B;">&gt;</span> <span style="color: #ff0055;">2</span><span style="color: #ff0055;">2'h3F_ffff</span><span style="color: #9F79EE;">&#41;</span> <span style="color: #5D478B;">?</span> 'b0 <span style="color: #5D478B;">:</span> x1_imag <span style="color: #5D478B;">+</span> <span style="color: #ff0055;">5</span> <span style="color: #5D478B;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; x2_imag <span style="color: #5D478B;">=</span> <span style="color: #9F79EE;">&#40;</span>x2_imag <span style="color: #5D478B;">&gt;</span> <span style="color: #ff0055;">2</span><span style="color: #ff0055;">2'h3F_ffff</span><span style="color: #9F79EE;">&#41;</span> <span style="color: #5D478B;">?</span> 'b0 <span style="color: #5D478B;">:</span> x2_imag <span style="color: #5D478B;">+</span> <span style="color: #ff0055;">3</span> <span style="color: #5D478B;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; x3_imag <span style="color: #5D478B;">=</span> <span style="color: #9F79EE;">&#40;</span>x3_imag <span style="color: #5D478B;">&gt;</span> <span style="color: #ff0055;">2</span><span style="color: #ff0055;">2'h3F_ffff</span><span style="color: #9F79EE;">&#41;</span> <span style="color: #5D478B;">?</span> 'b0 <span style="color: #5D478B;">:</span> x3_imag <span style="color: #5D478B;">+</span> <span style="color: #ff0055;">6</span> <span style="color: #5D478B;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; x4_imag <span style="color: #5D478B;">=</span> <span style="color: #9F79EE;">&#40;</span>x4_imag <span style="color: #5D478B;">&gt;</span> <span style="color: #ff0055;">2</span><span style="color: #ff0055;">2'h3F_ffff</span><span style="color: #9F79EE;">&#41;</span> <span style="color: #5D478B;">?</span> 'b0 <span style="color: #5D478B;">:</span> x4_imag <span style="color: #5D478B;">+</span> <span style="color: #ff0055;">4</span> <span style="color: #5D478B;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; x5_imag <span style="color: #5D478B;">=</span> <span style="color: #9F79EE;">&#40;</span>x5_imag <span style="color: #5D478B;">&gt;</span> <span style="color: #ff0055;">2</span><span style="color: #ff0055;">2'h3F_ffff</span><span style="color: #9F79EE;">&#41;</span> <span style="color: #5D478B;">?</span> 'b0 <span style="color: #5D478B;">:</span> x5_imag <span style="color: #5D478B;">+</span> <span style="color: #ff0055;">8</span> <span style="color: #5D478B;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; x6_imag <span style="color: #5D478B;">=</span> <span style="color: #9F79EE;">&#40;</span>x6_imag <span style="color: #5D478B;">&gt;</span> <span style="color: #ff0055;">2</span><span style="color: #ff0055;">2'h3F_ffff</span><span style="color: #9F79EE;">&#41;</span> <span style="color: #5D478B;">?</span> 'b0 <span style="color: #5D478B;">:</span> x6_imag <span style="color: #5D478B;">+</span> <span style="color: #ff0055;">11</span> <span style="color: #5D478B;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; x7_imag <span style="color: #5D478B;">=</span> <span style="color: #9F79EE;">&#40;</span>x7_imag <span style="color: #5D478B;">&gt;</span> <span style="color: #ff0055;">2</span><span style="color: #ff0055;">2'h3F_ffff</span><span style="color: #9F79EE;">&#41;</span> <span style="color: #5D478B;">?</span> 'b0 <span style="color: #5D478B;">:</span> x7_imag <span style="color: #5D478B;">+</span> <span style="color: #ff0055;">7</span> <span style="color: #5D478B;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #A52A2A; font-weight: bold;">end</span><br />
&nbsp; &nbsp; <span style="color: #A52A2A; font-weight: bold;">end</span><br />
<br />
&nbsp; &nbsp;<span style="color: #00008B; font-style: italic;">//finish simulation</span><br />
&nbsp; &nbsp;<span style="color: #A52A2A; font-weight: bold;">initial</span> <span style="color: #5D478B;">#</span><span style="color: #ff0055;">1000</span> &nbsp; &nbsp; &nbsp; <span style="color: #9932CC;">$finish</span> <span style="color: #5D478B;">;</span><br />
<span style="color: #A52A2A; font-weight: bold;">endmodule</span><br />
</div></div>
<p><strong>仿真结果</strong></p>
<p>大致可以看出，FFT 结果可以流水输出。</p>
<p><img decoding="async" src="https://www.runoob.com/wp-content/uploads/2020/10/Ax6nfRQh1amzJmPE.png" alt="" /></p>

<p>用 matlab 自带的 FFT 函数对相同数据进行运算，前 2 组数据 FFT 结果如下。</p><p>
可以看出，第一次输入的数据信号只有实部有效时，FFT 结果是完全一样的。</p><p>
但是第二次输入的数据复部也有信号，此时两者之间的结果开始有误差，有时误差还很大。</p>
<p><img decoding="async" src="https://www.runoob.com/wp-content/uploads/2020/10/aq7TX9tZrWCmGahi.png" alt="" /></p>

<p>用 matlab 对 Verilog 实现的 FFT 过程进行模拟，发现此过程的 FFT 结果和 Verilog 实现的 FFT 结果基本一致。</p><p>
将有误差的两种 FFT 结果取绝对值进行比较，图示如下。</p><p>
可以看出，FFT 结果的趋势大致相同，但在个别点有肉眼可见的误差。</p>
<p><img decoding="async" src="https://www.runoob.com/wp-content/uploads/2020/10/V7YHsCSb55OzbmlE.png" alt="" /></p>
<p>
<strong>设计总结：</strong></p><p>
就如设计蝶形单元时所说，旋转因子量化时，位宽的选择就会引入误差。</p><p>
而且每个蝶形单元的运算结果都会进行截取，也会引入误差。</p><p>
matlab 计算 FFT 时不用考虑精度问题，以其最高精度对数据进行 FFT 计算。</p><p>
以上所述，都会导致最后两种 FFT 计算方式结果的差异。</p><p>
感兴趣的学者，可以将旋转因子和输入数据位宽再进行一定的增加，FFT 点数也可以增加，然后再进行仿真对比，相对误差应该会减小。</p>

<h3>附录：matlab 使用</h3>
<p><strong>生成旋转因子</strong></p><p>
8 点 FFT 只需要用到 4 个旋转因子。旋转因子扩大倍数为 8192。</p>
<div class="example"><h2 class="example">实例</h2> <div class="example_code">
clear all<span style="color: #5D478B;">;</span>close all<span style="color: #5D478B;">;</span>clc<span style="color: #5D478B;">;</span><br />
<span style="color: #5D478B;">%=======================================================</span><br />
<span style="color: #5D478B;">%</span> Wnr calcuting<br />
<span style="color: #5D478B;">%=======================================================</span><br />
<span style="color: #A52A2A; font-weight: bold;">for</span> r <span style="color: #5D478B;">=</span> <span style="color: #ff0055;">0</span><span style="color: #5D478B;">:</span><span style="color: #ff0055;">3</span> <br />
&nbsp; &nbsp; Wnr_factor &nbsp;<span style="color: #5D478B;">=</span> cos<span style="color: #9F79EE;">&#40;</span>pi<span style="color: #5D478B;">/</span><span style="color: #ff0055;">4</span><span style="color: #5D478B;">*</span>r<span style="color: #9F79EE;">&#41;</span> <span style="color: #5D478B;">-</span> j<span style="color: #5D478B;">*</span>sin<span style="color: #9F79EE;">&#40;</span>pi<span style="color: #5D478B;">/</span><span style="color: #ff0055;">4</span><span style="color: #5D478B;">*</span>r<span style="color: #9F79EE;">&#41;</span> <span style="color: #5D478B;">;</span><br />
&nbsp; &nbsp; Wnr_integer <span style="color: #5D478B;">=</span> floor<span style="color: #9F79EE;">&#40;</span>Wnr_factor <span style="color: #5D478B;">*</span> <span style="color: #ff0055;">2</span><span style="color: #5D478B;">^</span><span style="color: #ff0055;">13</span><span style="color: #9F79EE;">&#41;</span> <span style="color: #5D478B;">;</span><br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; <span style="color: #A52A2A; font-weight: bold;">if</span> <span style="color: #9F79EE;">&#40;</span><span style="color: #A52A2A; font-weight: bold;">real</span><span style="color: #9F79EE;">&#40;</span>Wnr_integer<span style="color: #9F79EE;">&#41;</span><span style="color: #5D478B;">&lt;</span><span style="color: #ff0055;">0</span><span style="color: #9F79EE;">&#41;</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; Wnr_real &nbsp; &nbsp;<span style="color: #5D478B;">=</span> <span style="color: #A52A2A; font-weight: bold;">real</span><span style="color: #9F79EE;">&#40;</span>Wnr_integer<span style="color: #9F79EE;">&#41;</span> <span style="color: #5D478B;">+</span> <span style="color: #ff0055;">2</span><span style="color: #5D478B;">^</span><span style="color: #ff0055;">16</span> <span style="color: #5D478B;">;</span> <span style="color: #5D478B;">%</span>负数的补码<br />
&nbsp; &nbsp; <span style="color: #A52A2A; font-weight: bold;">else</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; Wnr_real &nbsp; &nbsp;<span style="color: #5D478B;">=</span> <span style="color: #A52A2A; font-weight: bold;">real</span><span style="color: #9F79EE;">&#40;</span>Wnr_integer<span style="color: #9F79EE;">&#41;</span> <span style="color: #5D478B;">;</span><br />
&nbsp; &nbsp; <span style="color: #A52A2A; font-weight: bold;">end</span><br />
&nbsp; &nbsp; <span style="color: #A52A2A; font-weight: bold;">if</span> <span style="color: #9F79EE;">&#40;</span>imag<span style="color: #9F79EE;">&#40;</span>Wnr_integer<span style="color: #9F79EE;">&#41;</span><span style="color: #5D478B;">&lt;</span><span style="color: #ff0055;">0</span><span style="color: #9F79EE;">&#41;</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; Wnr_imag &nbsp; &nbsp;<span style="color: #5D478B;">=</span> imag<span style="color: #9F79EE;">&#40;</span>Wnr_integer<span style="color: #9F79EE;">&#41;</span> <span style="color: #5D478B;">+</span> <span style="color: #ff0055;">2</span><span style="color: #5D478B;">^</span><span style="color: #ff0055;">16</span> <span style="color: #5D478B;">;</span> <br />
&nbsp; &nbsp; <span style="color: #A52A2A; font-weight: bold;">else</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; Wnr_imag &nbsp; &nbsp;<span style="color: #5D478B;">=</span> imag<span style="color: #9F79EE;">&#40;</span>Wnr_integer<span style="color: #9F79EE;">&#41;</span><span style="color: #5D478B;">;</span><br />
&nbsp; &nbsp; <span style="color: #A52A2A; font-weight: bold;">end</span><br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; Wnr<span style="color: #9F79EE;">&#40;</span><span style="color: #ff0055;">2</span><span style="color: #5D478B;">*</span>r<span style="color: #5D478B;">+</span><span style="color: #ff0055;">1</span><span style="color: #5D478B;">,:</span><span style="color: #9F79EE;">&#41;</span> &nbsp;<span style="color: #5D478B;">=</span> &nbsp;dec2hex<span style="color: #9F79EE;">&#40;</span>Wnr_real<span style="color: #9F79EE;">&#41;</span> &nbsp; <span style="color: #5D478B;">%</span>实部<br />
&nbsp; &nbsp; Wnr<span style="color: #9F79EE;">&#40;</span><span style="color: #ff0055;">2</span><span style="color: #5D478B;">*</span>r<span style="color: #5D478B;">+</span><span style="color: #ff0055;">2</span><span style="color: #5D478B;">,:</span><span style="color: #9F79EE;">&#41;</span> &nbsp;<span style="color: #5D478B;">=</span> &nbsp;dec2hex<span style="color: #9F79EE;">&#40;</span>Wnr_imag<span style="color: #9F79EE;">&#41;</span> &nbsp; <span style="color: #5D478B;">%</span>虚部<br />
<span style="color: #A52A2A; font-weight: bold;">end</span><br />
</div></div>
<p><strong>FFT 结果对比</strong></p>
<p>matlab 模拟 Verilog 实现 FFT 的过程如下，也包括 2 种 FFT 结果的对比。</p>
<div class="example"><h2 class="example">实例</h2> <div class="example_code">
clear all<span style="color: #5D478B;">;</span>close all<span style="color: #5D478B;">;</span>clc<span style="color: #5D478B;">;</span><br />
<span style="color: #5D478B;">%=======================================================</span><br />
<span style="color: #5D478B;">%</span> 8dots fft<br />
<span style="color: #5D478B;">%=======================================================</span><br />
<span style="color: #A52A2A; font-weight: bold;">for</span> r<span style="color: #5D478B;">=</span><span style="color: #ff0055;">0</span><span style="color: #5D478B;">:</span><span style="color: #ff0055;">3</span><br />
&nbsp; &nbsp; Wnr<span style="color: #9F79EE;">&#40;</span>r<span style="color: #5D478B;">+</span><span style="color: #ff0055;">1</span><span style="color: #9F79EE;">&#41;</span> &nbsp;<span style="color: #5D478B;">=</span> cos<span style="color: #9F79EE;">&#40;</span>pi<span style="color: #5D478B;">/</span><span style="color: #ff0055;">4</span><span style="color: #5D478B;">*</span>r<span style="color: #9F79EE;">&#41;</span> <span style="color: #5D478B;">-</span> j<span style="color: #5D478B;">*</span>sin<span style="color: #9F79EE;">&#40;</span>pi<span style="color: #5D478B;">/</span><span style="color: #ff0055;">4</span><span style="color: #5D478B;">*</span>r<span style="color: #9F79EE;">&#41;</span> <span style="color: #5D478B;">;</span><br />
<span style="color: #A52A2A; font-weight: bold;">end</span><br />
x &nbsp; &nbsp; &nbsp; <span style="color: #5D478B;">=</span> <span style="color: #9F79EE;">&#91;</span><span style="color: #ff0055;">10</span><span style="color: #5D478B;">,</span> <span style="color: #ff0055;">20</span><span style="color: #5D478B;">,</span> <span style="color: #ff0055;">30</span><span style="color: #5D478B;">,</span> <span style="color: #ff0055;">40</span><span style="color: #5D478B;">,</span> <span style="color: #ff0055;">10</span><span style="color: #5D478B;">,</span> <span style="color: #ff0055;">20</span> <span style="color: #5D478B;">,</span><span style="color: #ff0055;">30</span> <span style="color: #5D478B;">,</span><span style="color: #ff0055;">40</span><span style="color: #9F79EE;">&#93;</span><span style="color: #5D478B;">;</span><br />
step &nbsp; &nbsp;<span style="color: #5D478B;">=</span> <span style="color: #9F79EE;">&#91;</span><span style="color: #ff0055;">1</span><span style="color: #5D478B;">+</span>2j<span style="color: #5D478B;">,</span> <span style="color: #ff0055;">1</span><span style="color: #5D478B;">+</span>5j<span style="color: #5D478B;">,</span> <span style="color: #ff0055;">31</span><span style="color: #5D478B;">+</span>3j<span style="color: #5D478B;">,</span> <span style="color: #ff0055;">1</span><span style="color: #5D478B;">+</span>6j<span style="color: #5D478B;">,</span> <span style="color: #ff0055;">23</span><span style="color: #5D478B;">+</span>4j<span style="color: #5D478B;">,</span> <span style="color: #ff0055;">1</span><span style="color: #5D478B;">+</span>8j<span style="color: #5D478B;">,</span> <span style="color: #ff0055;">6</span><span style="color: #5D478B;">+</span>11j<span style="color: #5D478B;">,</span> <span style="color: #ff0055;">1</span><span style="color: #5D478B;">+</span>7j<span style="color: #9F79EE;">&#93;</span><span style="color: #5D478B;">;</span><br />
x2 &nbsp; &nbsp; &nbsp;<span style="color: #5D478B;">=</span> x <span style="color: #5D478B;">+</span> step<span style="color: #5D478B;">;</span><br />
xm0 &nbsp; &nbsp; <span style="color: #5D478B;">=</span> <span style="color: #9F79EE;">&#91;</span>x2<span style="color: #9F79EE;">&#40;</span><span style="color: #ff0055;">0</span><span style="color: #5D478B;">+</span><span style="color: #ff0055;">1</span><span style="color: #9F79EE;">&#41;</span><span style="color: #5D478B;">,</span> x2<span style="color: #9F79EE;">&#40;</span><span style="color: #ff0055;">4</span><span style="color: #5D478B;">+</span><span style="color: #ff0055;">1</span><span style="color: #9F79EE;">&#41;</span><span style="color: #5D478B;">,</span> x2<span style="color: #9F79EE;">&#40;</span><span style="color: #ff0055;">2</span><span style="color: #5D478B;">+</span><span style="color: #ff0055;">1</span><span style="color: #9F79EE;">&#41;</span><span style="color: #5D478B;">,</span> x2<span style="color: #9F79EE;">&#40;</span><span style="color: #ff0055;">6</span><span style="color: #5D478B;">+</span><span style="color: #ff0055;">1</span><span style="color: #9F79EE;">&#41;</span><span style="color: #5D478B;">,</span> x2<span style="color: #9F79EE;">&#40;</span><span style="color: #ff0055;">1</span><span style="color: #5D478B;">+</span><span style="color: #ff0055;">1</span><span style="color: #9F79EE;">&#41;</span><span style="color: #5D478B;">,</span> x2<span style="color: #9F79EE;">&#40;</span><span style="color: #ff0055;">5</span><span style="color: #5D478B;">+</span><span style="color: #ff0055;">1</span><span style="color: #9F79EE;">&#41;</span><span style="color: #5D478B;">,</span> &nbsp; &nbsp; &nbsp; &nbsp; x2<span style="color: #9F79EE;">&#40;</span><span style="color: #ff0055;">3</span><span style="color: #5D478B;">+</span><span style="color: #ff0055;">1</span><span style="color: #9F79EE;">&#41;</span><span style="color: #5D478B;">,</span> x2<span style="color: #9F79EE;">&#40;</span><span style="color: #ff0055;">7</span><span style="color: #5D478B;">+</span><span style="color: #ff0055;">1</span><span style="color: #9F79EE;">&#41;</span><span style="color: #9F79EE;">&#93;</span> <span style="color: #5D478B;">;</span><br />
<br />
<span style="color: #5D478B;">%%</span> stage1 <br />
xm1<span style="color: #9F79EE;">&#40;</span><span style="color: #ff0055;">1</span><span style="color: #9F79EE;">&#41;</span> <span style="color: #5D478B;">=</span> xm0<span style="color: #9F79EE;">&#40;</span><span style="color: #ff0055;">1</span><span style="color: #9F79EE;">&#41;</span> <span style="color: #5D478B;">+</span> xm0<span style="color: #9F79EE;">&#40;</span><span style="color: #ff0055;">2</span><span style="color: #9F79EE;">&#41;</span><span style="color: #5D478B;">*</span>Wnr<span style="color: #9F79EE;">&#40;</span><span style="color: #ff0055;">1</span><span style="color: #9F79EE;">&#41;</span> <span style="color: #5D478B;">;</span><br />
xm1<span style="color: #9F79EE;">&#40;</span><span style="color: #ff0055;">2</span><span style="color: #9F79EE;">&#41;</span> <span style="color: #5D478B;">=</span> xm0<span style="color: #9F79EE;">&#40;</span><span style="color: #ff0055;">1</span><span style="color: #9F79EE;">&#41;</span> <span style="color: #5D478B;">-</span> xm0<span style="color: #9F79EE;">&#40;</span><span style="color: #ff0055;">2</span><span style="color: #9F79EE;">&#41;</span><span style="color: #5D478B;">*</span>Wnr<span style="color: #9F79EE;">&#40;</span><span style="color: #ff0055;">1</span><span style="color: #9F79EE;">&#41;</span> <span style="color: #5D478B;">;</span><br />
xm1<span style="color: #9F79EE;">&#40;</span><span style="color: #ff0055;">3</span><span style="color: #9F79EE;">&#41;</span> <span style="color: #5D478B;">=</span> xm0<span style="color: #9F79EE;">&#40;</span><span style="color: #ff0055;">3</span><span style="color: #9F79EE;">&#41;</span> <span style="color: #5D478B;">+</span> xm0<span style="color: #9F79EE;">&#40;</span><span style="color: #ff0055;">4</span><span style="color: #9F79EE;">&#41;</span><span style="color: #5D478B;">*</span>Wnr<span style="color: #9F79EE;">&#40;</span><span style="color: #ff0055;">1</span><span style="color: #9F79EE;">&#41;</span> <span style="color: #5D478B;">;</span><br />
xm1<span style="color: #9F79EE;">&#40;</span><span style="color: #ff0055;">4</span><span style="color: #9F79EE;">&#41;</span> <span style="color: #5D478B;">=</span> xm0<span style="color: #9F79EE;">&#40;</span><span style="color: #ff0055;">3</span><span style="color: #9F79EE;">&#41;</span> <span style="color: #5D478B;">-</span> xm0<span style="color: #9F79EE;">&#40;</span><span style="color: #ff0055;">4</span><span style="color: #9F79EE;">&#41;</span><span style="color: #5D478B;">*</span>Wnr<span style="color: #9F79EE;">&#40;</span><span style="color: #ff0055;">1</span><span style="color: #9F79EE;">&#41;</span> <span style="color: #5D478B;">;</span><br />
xm1<span style="color: #9F79EE;">&#40;</span><span style="color: #ff0055;">5</span><span style="color: #9F79EE;">&#41;</span> <span style="color: #5D478B;">=</span> xm0<span style="color: #9F79EE;">&#40;</span><span style="color: #ff0055;">5</span><span style="color: #9F79EE;">&#41;</span> <span style="color: #5D478B;">+</span> xm0<span style="color: #9F79EE;">&#40;</span><span style="color: #ff0055;">6</span><span style="color: #9F79EE;">&#41;</span><span style="color: #5D478B;">*</span>Wnr<span style="color: #9F79EE;">&#40;</span><span style="color: #ff0055;">1</span><span style="color: #9F79EE;">&#41;</span> <span style="color: #5D478B;">;</span><br />
xm1<span style="color: #9F79EE;">&#40;</span><span style="color: #ff0055;">6</span><span style="color: #9F79EE;">&#41;</span> <span style="color: #5D478B;">=</span> xm0<span style="color: #9F79EE;">&#40;</span><span style="color: #ff0055;">5</span><span style="color: #9F79EE;">&#41;</span> <span style="color: #5D478B;">-</span> xm0<span style="color: #9F79EE;">&#40;</span><span style="color: #ff0055;">6</span><span style="color: #9F79EE;">&#41;</span><span style="color: #5D478B;">*</span>Wnr<span style="color: #9F79EE;">&#40;</span><span style="color: #ff0055;">1</span><span style="color: #9F79EE;">&#41;</span> <span style="color: #5D478B;">;</span><br />
xm1<span style="color: #9F79EE;">&#40;</span><span style="color: #ff0055;">7</span><span style="color: #9F79EE;">&#41;</span> <span style="color: #5D478B;">=</span> xm0<span style="color: #9F79EE;">&#40;</span><span style="color: #ff0055;">7</span><span style="color: #9F79EE;">&#41;</span> <span style="color: #5D478B;">+</span> xm0<span style="color: #9F79EE;">&#40;</span><span style="color: #ff0055;">8</span><span style="color: #9F79EE;">&#41;</span><span style="color: #5D478B;">*</span>Wnr<span style="color: #9F79EE;">&#40;</span><span style="color: #ff0055;">1</span><span style="color: #9F79EE;">&#41;</span> <span style="color: #5D478B;">;</span><br />
xm1<span style="color: #9F79EE;">&#40;</span><span style="color: #ff0055;">8</span><span style="color: #9F79EE;">&#41;</span> <span style="color: #5D478B;">=</span> xm0<span style="color: #9F79EE;">&#40;</span><span style="color: #ff0055;">7</span><span style="color: #9F79EE;">&#41;</span> <span style="color: #5D478B;">-</span> xm0<span style="color: #9F79EE;">&#40;</span><span style="color: #ff0055;">8</span><span style="color: #9F79EE;">&#41;</span><span style="color: #5D478B;">*</span>Wnr<span style="color: #9F79EE;">&#40;</span><span style="color: #ff0055;">1</span><span style="color: #9F79EE;">&#41;</span> <span style="color: #5D478B;">;</span><br />
floor<span style="color: #9F79EE;">&#40;</span>xm1<span style="color: #9F79EE;">&#40;</span><span style="color: #5D478B;">:</span><span style="color: #9F79EE;">&#41;</span><span style="color: #9F79EE;">&#41;</span><br />
<br />
<span style="color: #5D478B;">%%</span> stage2<br />
xm2<span style="color: #9F79EE;">&#40;</span><span style="color: #ff0055;">1</span><span style="color: #9F79EE;">&#41;</span> <span style="color: #5D478B;">=</span> xm1<span style="color: #9F79EE;">&#40;</span><span style="color: #ff0055;">1</span><span style="color: #9F79EE;">&#41;</span> <span style="color: #5D478B;">+</span> xm1<span style="color: #9F79EE;">&#40;</span><span style="color: #ff0055;">3</span><span style="color: #9F79EE;">&#41;</span><span style="color: #5D478B;">*</span>Wnr<span style="color: #9F79EE;">&#40;</span><span style="color: #ff0055;">1</span><span style="color: #9F79EE;">&#41;</span> <span style="color: #5D478B;">;</span><br />
xm2<span style="color: #9F79EE;">&#40;</span><span style="color: #ff0055;">3</span><span style="color: #9F79EE;">&#41;</span> <span style="color: #5D478B;">=</span> xm1<span style="color: #9F79EE;">&#40;</span><span style="color: #ff0055;">1</span><span style="color: #9F79EE;">&#41;</span> <span style="color: #5D478B;">-</span> xm1<span style="color: #9F79EE;">&#40;</span><span style="color: #ff0055;">3</span><span style="color: #9F79EE;">&#41;</span><span style="color: #5D478B;">*</span>Wnr<span style="color: #9F79EE;">&#40;</span><span style="color: #ff0055;">1</span><span style="color: #9F79EE;">&#41;</span> <span style="color: #5D478B;">;</span><br />
xm2<span style="color: #9F79EE;">&#40;</span><span style="color: #ff0055;">2</span><span style="color: #9F79EE;">&#41;</span> <span style="color: #5D478B;">=</span> xm1<span style="color: #9F79EE;">&#40;</span><span style="color: #ff0055;">2</span><span style="color: #9F79EE;">&#41;</span> <span style="color: #5D478B;">+</span> xm1<span style="color: #9F79EE;">&#40;</span><span style="color: #ff0055;">4</span><span style="color: #9F79EE;">&#41;</span><span style="color: #5D478B;">*</span>Wnr<span style="color: #9F79EE;">&#40;</span><span style="color: #ff0055;">2</span><span style="color: #9F79EE;">&#41;</span> <span style="color: #5D478B;">;</span><br />
xm2<span style="color: #9F79EE;">&#40;</span><span style="color: #ff0055;">4</span><span style="color: #9F79EE;">&#41;</span> <span style="color: #5D478B;">=</span> xm1<span style="color: #9F79EE;">&#40;</span><span style="color: #ff0055;">2</span><span style="color: #9F79EE;">&#41;</span> <span style="color: #5D478B;">-</span> xm1<span style="color: #9F79EE;">&#40;</span><span style="color: #ff0055;">4</span><span style="color: #9F79EE;">&#41;</span><span style="color: #5D478B;">*</span>Wnr<span style="color: #9F79EE;">&#40;</span><span style="color: #ff0055;">2</span><span style="color: #9F79EE;">&#41;</span> <span style="color: #5D478B;">;</span><br />
xm2<span style="color: #9F79EE;">&#40;</span><span style="color: #ff0055;">5</span><span style="color: #9F79EE;">&#41;</span> <span style="color: #5D478B;">=</span> xm1<span style="color: #9F79EE;">&#40;</span><span style="color: #ff0055;">5</span><span style="color: #9F79EE;">&#41;</span> <span style="color: #5D478B;">+</span> xm1<span style="color: #9F79EE;">&#40;</span><span style="color: #ff0055;">7</span><span style="color: #9F79EE;">&#41;</span><span style="color: #5D478B;">*</span>Wnr<span style="color: #9F79EE;">&#40;</span><span style="color: #ff0055;">1</span><span style="color: #9F79EE;">&#41;</span> <span style="color: #5D478B;">;</span><br />
xm2<span style="color: #9F79EE;">&#40;</span><span style="color: #ff0055;">7</span><span style="color: #9F79EE;">&#41;</span> <span style="color: #5D478B;">=</span> xm1<span style="color: #9F79EE;">&#40;</span><span style="color: #ff0055;">5</span><span style="color: #9F79EE;">&#41;</span> <span style="color: #5D478B;">-</span> xm1<span style="color: #9F79EE;">&#40;</span><span style="color: #ff0055;">7</span><span style="color: #9F79EE;">&#41;</span><span style="color: #5D478B;">*</span>Wnr<span style="color: #9F79EE;">&#40;</span><span style="color: #ff0055;">1</span><span style="color: #9F79EE;">&#41;</span> <span style="color: #5D478B;">;</span><br />
xm2<span style="color: #9F79EE;">&#40;</span><span style="color: #ff0055;">6</span><span style="color: #9F79EE;">&#41;</span> <span style="color: #5D478B;">=</span> xm1<span style="color: #9F79EE;">&#40;</span><span style="color: #ff0055;">6</span><span style="color: #9F79EE;">&#41;</span> <span style="color: #5D478B;">+</span> xm1<span style="color: #9F79EE;">&#40;</span><span style="color: #ff0055;">8</span><span style="color: #9F79EE;">&#41;</span><span style="color: #5D478B;">*</span>Wnr<span style="color: #9F79EE;">&#40;</span><span style="color: #ff0055;">2</span><span style="color: #9F79EE;">&#41;</span> <span style="color: #5D478B;">;</span><br />
xm2<span style="color: #9F79EE;">&#40;</span><span style="color: #ff0055;">8</span><span style="color: #9F79EE;">&#41;</span> <span style="color: #5D478B;">=</span> xm1<span style="color: #9F79EE;">&#40;</span><span style="color: #ff0055;">6</span><span style="color: #9F79EE;">&#41;</span> <span style="color: #5D478B;">-</span> xm1<span style="color: #9F79EE;">&#40;</span><span style="color: #ff0055;">8</span><span style="color: #9F79EE;">&#41;</span><span style="color: #5D478B;">*</span>Wnr<span style="color: #9F79EE;">&#40;</span><span style="color: #ff0055;">2</span><span style="color: #9F79EE;">&#41;</span> <span style="color: #5D478B;">;</span><br />
floor<span style="color: #9F79EE;">&#40;</span>xm2<span style="color: #9F79EE;">&#40;</span><span style="color: #5D478B;">:</span><span style="color: #9F79EE;">&#41;</span><span style="color: #9F79EE;">&#41;</span><br />
<br />
<span style="color: #5D478B;">%%</span> stage3<br />
xm3<span style="color: #9F79EE;">&#40;</span><span style="color: #ff0055;">1</span><span style="color: #9F79EE;">&#41;</span> <span style="color: #5D478B;">=</span> xm2<span style="color: #9F79EE;">&#40;</span><span style="color: #ff0055;">1</span><span style="color: #9F79EE;">&#41;</span> <span style="color: #5D478B;">+</span> xm2<span style="color: #9F79EE;">&#40;</span><span style="color: #ff0055;">5</span><span style="color: #9F79EE;">&#41;</span><span style="color: #5D478B;">*</span>Wnr<span style="color: #9F79EE;">&#40;</span><span style="color: #ff0055;">1</span><span style="color: #9F79EE;">&#41;</span> <span style="color: #5D478B;">;</span><br />
xm3<span style="color: #9F79EE;">&#40;</span><span style="color: #ff0055;">5</span><span style="color: #9F79EE;">&#41;</span> <span style="color: #5D478B;">=</span> xm2<span style="color: #9F79EE;">&#40;</span><span style="color: #ff0055;">1</span><span style="color: #9F79EE;">&#41;</span> <span style="color: #5D478B;">-</span> xm2<span style="color: #9F79EE;">&#40;</span><span style="color: #ff0055;">5</span><span style="color: #9F79EE;">&#41;</span><span style="color: #5D478B;">*</span>Wnr<span style="color: #9F79EE;">&#40;</span><span style="color: #ff0055;">1</span><span style="color: #9F79EE;">&#41;</span> <span style="color: #5D478B;">;</span><br />
xm3<span style="color: #9F79EE;">&#40;</span><span style="color: #ff0055;">2</span><span style="color: #9F79EE;">&#41;</span> <span style="color: #5D478B;">=</span> xm2<span style="color: #9F79EE;">&#40;</span><span style="color: #ff0055;">2</span><span style="color: #9F79EE;">&#41;</span> <span style="color: #5D478B;">+</span> xm2<span style="color: #9F79EE;">&#40;</span><span style="color: #ff0055;">6</span><span style="color: #9F79EE;">&#41;</span><span style="color: #5D478B;">*</span>Wnr<span style="color: #9F79EE;">&#40;</span><span style="color: #ff0055;">2</span><span style="color: #9F79EE;">&#41;</span> <span style="color: #5D478B;">;</span><br />
xm3<span style="color: #9F79EE;">&#40;</span><span style="color: #ff0055;">6</span><span style="color: #9F79EE;">&#41;</span> <span style="color: #5D478B;">=</span> xm2<span style="color: #9F79EE;">&#40;</span><span style="color: #ff0055;">2</span><span style="color: #9F79EE;">&#41;</span> <span style="color: #5D478B;">-</span> xm2<span style="color: #9F79EE;">&#40;</span><span style="color: #ff0055;">6</span><span style="color: #9F79EE;">&#41;</span><span style="color: #5D478B;">*</span>Wnr<span style="color: #9F79EE;">&#40;</span><span style="color: #ff0055;">2</span><span style="color: #9F79EE;">&#41;</span> <span style="color: #5D478B;">;</span><br />
xm3<span style="color: #9F79EE;">&#40;</span><span style="color: #ff0055;">3</span><span style="color: #9F79EE;">&#41;</span> <span style="color: #5D478B;">=</span> xm2<span style="color: #9F79EE;">&#40;</span><span style="color: #ff0055;">3</span><span style="color: #9F79EE;">&#41;</span> <span style="color: #5D478B;">+</span> xm2<span style="color: #9F79EE;">&#40;</span><span style="color: #ff0055;">7</span><span style="color: #9F79EE;">&#41;</span><span style="color: #5D478B;">*</span>Wnr<span style="color: #9F79EE;">&#40;</span><span style="color: #ff0055;">3</span><span style="color: #9F79EE;">&#41;</span> <span style="color: #5D478B;">;</span><br />
xm3<span style="color: #9F79EE;">&#40;</span><span style="color: #ff0055;">7</span><span style="color: #9F79EE;">&#41;</span> <span style="color: #5D478B;">=</span> xm2<span style="color: #9F79EE;">&#40;</span><span style="color: #ff0055;">3</span><span style="color: #9F79EE;">&#41;</span> <span style="color: #5D478B;">-</span> xm2<span style="color: #9F79EE;">&#40;</span><span style="color: #ff0055;">7</span><span style="color: #9F79EE;">&#41;</span><span style="color: #5D478B;">*</span>Wnr<span style="color: #9F79EE;">&#40;</span><span style="color: #ff0055;">3</span><span style="color: #9F79EE;">&#41;</span> <span style="color: #5D478B;">;</span><br />
xm3<span style="color: #9F79EE;">&#40;</span><span style="color: #ff0055;">4</span><span style="color: #9F79EE;">&#41;</span> <span style="color: #5D478B;">=</span> xm2<span style="color: #9F79EE;">&#40;</span><span style="color: #ff0055;">4</span><span style="color: #9F79EE;">&#41;</span> <span style="color: #5D478B;">+</span> xm2<span style="color: #9F79EE;">&#40;</span><span style="color: #ff0055;">8</span><span style="color: #9F79EE;">&#41;</span><span style="color: #5D478B;">*</span>Wnr<span style="color: #9F79EE;">&#40;</span><span style="color: #ff0055;">4</span><span style="color: #9F79EE;">&#41;</span> <span style="color: #5D478B;">;</span><br />
xm3<span style="color: #9F79EE;">&#40;</span><span style="color: #ff0055;">8</span><span style="color: #9F79EE;">&#41;</span> <span style="color: #5D478B;">=</span> xm2<span style="color: #9F79EE;">&#40;</span><span style="color: #ff0055;">4</span><span style="color: #9F79EE;">&#41;</span> <span style="color: #5D478B;">-</span> xm2<span style="color: #9F79EE;">&#40;</span><span style="color: #ff0055;">8</span><span style="color: #9F79EE;">&#41;</span><span style="color: #5D478B;">*</span>Wnr<span style="color: #9F79EE;">&#40;</span><span style="color: #ff0055;">4</span><span style="color: #9F79EE;">&#41;</span> <span style="color: #5D478B;">;</span><br />
floor<span style="color: #9F79EE;">&#40;</span>xm3<span style="color: #9F79EE;">&#40;</span><span style="color: #5D478B;">:</span><span style="color: #9F79EE;">&#41;</span><span style="color: #9F79EE;">&#41;</span><br />
<br />
<span style="color: #5D478B;">%%</span> fft<br />
fft1 <span style="color: #5D478B;">=</span> fft<span style="color: #9F79EE;">&#40;</span>x<span style="color: #9F79EE;">&#41;</span><br />
fft2 <span style="color: #5D478B;">=</span> fft<span style="color: #9F79EE;">&#40;</span>x2<span style="color: #9F79EE;">&#41;</span><br />
plot<span style="color: #9F79EE;">&#40;</span><span style="color: #ff0055;">1</span><span style="color: #5D478B;">:</span><span style="color: #ff0055;">8</span><span style="color: #5D478B;">,</span> abs<span style="color: #9F79EE;">&#40;</span>fft2<span style="color: #9F79EE;">&#41;</span><span style="color: #9F79EE;">&#41;</span><br />
hold on<br />
plot<span style="color: #9F79EE;">&#40;</span><span style="color: #ff0055;">1</span><span style="color: #5D478B;">:</span><span style="color: #ff0055;">8</span><span style="color: #5D478B;">,</span> abs<span style="color: #9F79EE;">&#40;</span>xm3<span style="color: #9F79EE;">&#41;</span><span style="color: #5D478B;">,</span> 'r'<span style="color: #9F79EE;">&#41;</span><br />
</div></div>
<h3>源码下载</h3>
<p><a href="../wp-content/uploads/2020/10/7.5fft.zip" download class="download">Download</a></p>				</div>
			</div>
			<div class="previous-next-links">
			<div class="previous-design-link">← <a href="../w3cnote/verilog-cic.html" rel="prev"> 7.4 Verilog CIC 滤波器设计</a> </div>
			<div class="next-design-link"><a href="../w3cnote/verilog-numerical-conversion.html" rel="next"> 8.1 Verilog 数值转换</a> →</div>
			</div>
						<div class="article-heading-ad" id="w3cnote-ad728">
			<script async src=""></script>
			<!-- 移动版 自动调整 -->
			<ins class="adsbygoogle"
			     style="display:inline-block;min-width:300px;max-width:970px;width:100%;height:90px"
			     data-ad-client="ca-pub-5751451760833794"
			     data-ad-slot="1691338467"
			     data-ad-format="horizontal"></ins>
			<script>
			(adsbygoogle = window.adsbygoogle || []).push({});
			</script>
			</div>
			<style>
@media screen and (max-width: 768px) {
	#w3cnote-ad728 {
		display: none;
	}
}
p.note-author {
    border-bottom: 1px solid #ddd;
    font-size: 18px;
    font-weight: bold;
    color: #78a15a;
    padding-bottom: 2px;
    margin-bottom: 4px;
}
</style>
<script>
var aid = 23260;
</script>
	</div>
		
	</div>
	<div class="listcol last right-column">

	<script type="text/javascript">
jQuery(document).ready(function ($){
	var total = $(".membership li").length;
	var left_list = '';
	href = window.location.href;
	
	$(".membership li").each(function(index, value){

		left_list += $(this).html();

		cur_href = $(this).find("a").attr("href");
		cur_obj = $(this);
		
		if(href.match(cur_href) != null) {
			if(index==0) {
				$(".previous-design-link").hide();
			}
			if(index==(total-1)) {
				$(".next-design-link").hide();
			}
			prev_href = cur_obj.prev("li").find("a").attr("href");
			prev_title = cur_obj.prev("li").find("a").attr("title");

			next_href = cur_obj.next("li").find("a").attr("href");
			next_title = cur_obj.next("li").find("a").attr("title");
			if(prev_title) {
				$(".previous-design-link a").attr("href", prev_href);
				$(".previous-design-link a").attr("title", prev_title);
				$(".previous-design-link a").text(prev_title);
			} else {
				$(".previous-design-link").html("");
			}

			if(next_title) {
				$(".next-design-link a").attr("href", next_href);
				$(".next-design-link a").attr("title", next_title);
				$(".next-design-link a").text(next_title);
			} else {
				$(".next-design-link").html("");
			}
		}
	});

	$("#leftcolumn").html(left_list);
});
	</script>
	<div class="sidebar-box cate-list">
	<div class="sidebar-box recommend-here list-link">
	<a href="javascript:void(0);">Verilog 教程</a>	</div>
	
	<ul class="membership">
		
	<li><a target="_top" data-id="22850" title="1.1 Verilog 教程" href="../w3cnote/verilog-tutorial.html" >1.1 Verilog 教程</a></li>
	
		
	<li><a target="_top" data-id="22851" title="1.2 Verilog 简介" href="../w3cnote/verilog-intro.html" >1.2 Verilog 简介</a></li>
	
		
	<li><a target="_top" data-id="22852" title="1.3 Verilog 环境搭建" href="../w3cnote/verilog-install.html" >1.3 Verilog 环境搭建</a></li>
	
		
	<li><a target="_top" data-id="22866" title="1.4 Verilog 设计方法" href="../w3cnote/verilog-design-method.html" >1.4 Verilog 设计方法</a></li>
	
		
	<li><a target="_top" data-id="22869" title="2.1 Verilog 基础语法" href="../w3cnote/verilog-basic-syntax.html" >2.1 Verilog 基础语法</a></li>
	
		
	<li><a target="_top" data-id="22870" title="2.2 Verilog 数值表示" href="../w3cnote/verilog-number.html" >2.2 Verilog 数值表示</a></li>
	
		
	<li><a target="_top" data-id="22871" title="2.3 Verilog 数据类型" href="../w3cnote/verilog-data-type.html" >2.3 Verilog 数据类型</a></li>
	
		
	<li><a target="_top" data-id="22872" title="2.4 Verilog 表达式" href="../w3cnote/verilog-expression.html" >2.4 Verilog 表达式</a></li>
	
		
	<li><a target="_top" data-id="22935" title="2.5 Verilog 编译指令" href="../w3cnote/verilog-compile-instruction.html" >2.5 Verilog 编译指令</a></li>
	
		
	<li><a target="_top" data-id="22931" title="3.1 Verilog 连续赋值" href="../w3cnote/verilog-assign.html" >3.1 Verilog 连续赋值</a></li>
	
		
	<li><a target="_top" data-id="22933" title="3.2 Verilog 时延" href="../w3cnote/verilog-time-delay.html" >3.2 Verilog 时延</a></li>
	
		
	<li><a target="_top" data-id="22936" title="4.1 Verilog 过程结构" href="../w3cnote/verilog-process-structure.html" >4.1 Verilog 过程结构</a></li>
	
		
	<li><a target="_top" data-id="22939" title="4.2 Verilog 过程赋值" href="../w3cnote/verilog-process-assign.html" >4.2 Verilog 过程赋值</a></li>
	
		
	<li><a target="_top" data-id="22941" title="4.3 Verilog 时序控制" href="../w3cnote/verilog-timing-control.html" >4.3 Verilog 时序控制</a></li>
	
		
	<li><a target="_top" data-id="22943" title="4.4 Verilog 语句块" href="../w3cnote/verilog-statements-block.html" >4.4 Verilog 语句块</a></li>
	
		
	<li><a target="_top" data-id="22948" title="4.5 Verilog 条件语句" href="../w3cnote/verilog-condition-statement.html" >4.5 Verilog 条件语句</a></li>
	
		
	<li><a target="_top" data-id="22950" title="4.6 Verilog 多路分支语句" href="../w3cnote/verilog-case.html" >4.6 Verilog 多路分支语句</a></li>
	
		
	<li><a target="_top" data-id="22951" title="4.7 Verilog 循环语句" href="../w3cnote/verilog-loop.html" >4.7 Verilog 循环语句</a></li>
	
		
	<li><a target="_top" data-id="22954" title="4.8 Verilog 过程连续赋值" href="../w3cnote/verilog-deassign.html" >4.8 Verilog 过程连续赋值</a></li>
	
		
	<li><a target="_top" data-id="22966" title="5.1 Verilog 模块与端口" href="../w3cnote/verilog-module-port.html" >5.1 Verilog 模块与端口</a></li>
	
		
	<li><a target="_top" data-id="22969" title="5.2 Verilog 模块例化" href="../w3cnote/verilog-generate.html" >5.2 Verilog 模块例化</a></li>
	
		
	<li><a target="_top" data-id="22972" title="5.3 Verilog 带参数例化" href="../w3cnote/verilog-defparam.html" >5.3 Verilog 带参数例化</a></li>
	
		
	<li><a target="_top" data-id="22975" title="6.1 Verilog 函数" href="../w3cnote/verilog-function.html" >6.1 Verilog 函数</a></li>
	
		
	<li><a target="_top" data-id="22982" title="6.2 Verilog 任务" href="../w3cnote/verilog-task.html" >6.2 Verilog 任务</a></li>
	
		
	<li><a target="_top" data-id="22990" title="6.3 Verilog 状态机" href="../w3cnote/verilog-fsm.html" >6.3 Verilog 状态机</a></li>
	
		
	<li><a target="_top" data-id="22999" title="6.4 Verilog 竞争与冒险" href="../w3cnote/verilog-competition-hazard.html" >6.4 Verilog 竞争与冒险</a></li>
	
		
	<li><a target="_top" data-id="23008" title="6.5 Verilog 避免 Latch" href="../w3cnote/verilog-latch.html" >6.5 Verilog 避免 Latch</a></li>
	
		
	<li><a target="_top" data-id="23011" title="6.6 Verilog 仿真激励" href="../w3cnote/verilog-testbench.html" >6.6 Verilog 仿真激励</a></li>
	
		
	<li><a target="_top" data-id="23015" title="6.7 Verilog 流水线" href="../w3cnote/verilog-pipeline-design.html" >6.7 Verilog 流水线</a></li>
	
		
	<li><a target="_top" data-id="23021" title="7.1 Verilog 除法器设计" href="../w3cnote/verilog-dividend.html" >7.1 Verilog 除法器设计</a></li>
	
		
	<li><a target="_top" data-id="23222" title="7.2 Verilog 并行 FIR 滤波器设计" href="../w3cnote/verilog-fir.html" >7.2 Verilog 并行 FIR 滤波器设计</a></li>
	
		
	<li><a target="_top" data-id="23230" title="7.3 Verilog 串行 FIR 滤波器设计" href="../w3cnote/verilog-serial-fir.html" >7.3 Verilog 串行 FIR 滤波器设计</a></li>
	
		
	<li><a target="_top" data-id="23236" title="7.4 Verilog CIC 滤波器设计" href="../w3cnote/verilog-cic.html" >7.4 Verilog CIC 滤波器设计</a></li>
	
		<li>
	7.5 Verilog FFT 设计	</li>
	
		
	<li><a target="_top" data-id="23309" title="7.6 Verilog DDS 设计" href="../w3cnote/verilog-dds.html" >7.6 Verilog DDS 设计</a></li>
	
		
	<li><a target="_top" data-id="23281" title="8.1 Verilog 数值转换" href="../w3cnote/verilog-numerical-conversion.html" >8.1 Verilog 数值转换</a></li>
	
	<li><a target="_top" title="Verilog 教程高级篇" href="../w3cnote/verilog2-tutorial.html" >Verilog 教程高级篇</a></li></ul></div>	</div>
</div>


<!-- 底部 -->
<div id="footer" class="mar-t50">
   <div class="runoob-block">
    <div class="runoob cf">
     <dl>
      <dt>
       在线实例
      </dt>
      <dd>
       &middot;<a target="_blank" href="../html/html-examples.html">HTML 实例</a>
      </dd>
      <dd>
       &middot;<a target="_blank" href="../css/css-examples.html">CSS 实例</a>
      </dd>
      <dd>
       &middot;<a target="_blank" href="../js/js-examples.html">JavaScript 实例</a>
      </dd>
      <dd>
       &middot;<a target="_blank" href="../ajx/ajax-examples.html">Ajax 实例</a>
      </dd>
       <dd>
       &middot;<a target="_blank" href="../jquery/jquery-examples.html">jQuery 实例</a>
      </dd>
      <dd>
       &middot;<a target="_blank" href="../xml/xml-examples.html">XML 实例</a>
      </dd>
      <dd>
       &middot;<a target="_blank" href="../java/java-examples.html">Java 实例</a>
      </dd>
     
     </dl>
     <dl>
      <dt>
      字符集&工具
      </dt>
      <dd>
       &middot; <a target="_blank" href="../charsets/html-charsets.html">HTML 字符集设置</a>
      </dd>
      <dd>
       &middot; <a target="_blank" href="../tags/html-ascii.html">HTML ASCII 字符集</a>
      </dd>
     <dd>
       &middot; <a target="_blank" href="https://c.runoob.com/front-end/6939/">JS 混淆/加密</a>
      </dd> 
      <dd>
       &middot; <a target="_blank" href="https://c.runoob.com/front-end/6232/">PNG/JPEG 图片压缩</a>
      </dd>
      <dd>
       &middot; <a target="_blank" href="../tags/html-colorpicker.html">HTML 拾色器</a>
      </dd>
      <dd>
       &middot; <a target="_blank" href="..//c.runoob.com/front-end/53">JSON 格式化工具</a>
      </dd>
      <dd>
       &middot; <a target="_blank" href="..//c.runoob.com/front-end/6680/">随机数生成器</a>
      </dd>
     </dl>
     <dl>
      <dt>
       最新更新
      </dt>
                   <dd>
       &middot;
      <a href="../matplotlib/matplotlib-imread.html" title="Matplotlib imread() 方法">Matplotlib imre...</a>
      </dd>
              <dd>
       &middot;
      <a href="../matplotlib/matplotlib-imsave.html" title="Matplotlib imsave() 方法">Matplotlib imsa...</a>
      </dd>
              <dd>
       &middot;
      <a href="../matplotlib/matplotlib-imshow.html" title="Matplotlib imshow() 方法">Matplotlib imsh...</a>
      </dd>
              <dd>
       &middot;
      <a href="../matplotlib/matplotlib-hist.html" title="Matplotlib 直方图">Matplotlib 直方图</a>
      </dd>
              <dd>
       &middot;
      <a href="../python3/python-func-object.html" title="Python object() 函数">Python object()...</a>
      </dd>
              <dd>
       &middot;
      <a href="../python3/python-ai-draw.html" title="Python AI 绘画">Python AI 绘画</a>
      </dd>
              <dd>
       &middot;
      <a href="../w3cnote/cursor-editor.html" title="神辅助 Cursor 编辑器，加入 GPT-4 让编码更轻松！">神辅助 Cursor ...</a>
      </dd>
             </dl>
     <dl>
      <dt>
       站点信息
      </dt>
      <dd>
       &middot;
       <a target="_blank" href="mailto:admin@runoob.com" rel="external nofollow">意见反馈</a>
       </dd>
      <dd>
       &middot;
      <a target="_blank" href="../disclaimer">免责声明</a>
       </dd>
      <dd>
       &middot;
       <a target="_blank" href="../aboutus">关于我们</a>
       </dd>
      <dd>
       &middot;
      <a target="_blank" href="../archives">文章归档</a>
      </dd>
    
     </dl>
    
     <div class="search-share">
      <div class="app-download">
        <div>
         <strong>关注微信</strong>
        </div>
      </div>
      <div class="share">
      <img width="128" height="128" src="/wp-content/themes/runoob/assets/images/qrcode.png" />
       </div>
     </div>
     
    </div>
   </div>
   <div class="w-1000 copyright">
     Copyright &copy; 2013-2023    <strong><a href="../" target="_blank">菜鸟教程</a></strong>&nbsp;
    <strong><a href="../" target="_blank">runoob.com</a></strong> All Rights Reserved. 备案号：<a target="_blank" rel="nofollow" href="https://beian.miit.gov.cn/">闽ICP备15012807号-1</a>
   </div>
  </div>
  <div class="fixed-btn">
    <a class="go-top" href="javascript:void(0)" title="返回顶部"> <i class="fa fa-angle-up"></i></a>
    <a class="qrcode"  href="javascript:void(0)" title="关注我们"><i class="fa fa-qrcode"></i></a>
    <a class="writer" style="display:none" href="javascript:void(0)"   title="标记/收藏"><i class="fa fa-star" aria-hidden="true"></i></a>
    <!-- qrcode modal -->
    <div id="bottom-qrcode" class="modal panel-modal hide fade in">
      <h4>微信关注</h4>
      <div class="panel-body"><img alt="微信关注" width="128" height="128" src="/wp-content/themes/runoob/assets/images/qrcode.png"></div> 
    </div>
  </div>

 <div style="display:none;">
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-84264393-2"></script>
<script>
  window.dataLayer = window.dataLayer || [];
  function gtag(){dataLayer.push(arguments);}
  gtag('js', new Date());

  gtag('config', 'UA-84264393-2');
</script>
<script>
var _hmt = _hmt || [];
(function() {
  var hm = document.createElement("script");
  hm.src = "https://hm.baidu.com/hm.js?3eec0b7da6548cf07db3bc477ea905ee";
  var s = document.getElementsByTagName("script")[0]; 
  s.parentNode.insertBefore(hm, s);
})();
</script>

</div>
<script>
window.jsui={
    www: 'https://www.runoob.com',
    uri: 'https://www.runoob.com/wp-content/themes/runoob'
};
</script>

<script src=""></script>
<script src=""></script>

</body>
</html>